[clang-tools-extra] r350916 - Adapt to CXXMethodDecl::getThisType change (NFC)

2019-01-10 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Thu Jan 10 18:12:31 2019
New Revision: 350916

URL: http://llvm.org/viewvc/llvm-project?rev=350916&view=rev
Log:
Adapt to CXXMethodDecl::getThisType change (NFC)

Summary:
https://reviews.llvm.org/D56509 changed the API of the
CXXMethodDecl::getThisType method. Adapt to the change (and re-apply
clang-format) to fix the clang-tidy build.


Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp?rev=350916&r1=350915&r2=350916&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp Thu 
Jan 10 18:12:31 2019
@@ -50,9 +50,7 @@ static BasesVector getParentsByGrandPare
 // TypePtr is the nearest base class to ThisClass between ThisClass and
 // GrandParent, where MemberDecl is overridden. TypePtr is the class the
 // check proposes to fix to.
-const Type *TypePtr =
-ActualMemberDecl->getThisType(ActualMemberDecl->getASTContext())
-.getTypePtr();
+const Type *TypePtr = ActualMemberDecl->getThisType().getTypePtr();
 const CXXRecordDecl *RecordDeclType = TypePtr->getPointeeCXXRecordDecl();
 assert(RecordDeclType && "TypePtr is not a pointer to CXXRecordDecl!");
 if (RecordDeclType->getCanonicalDecl()->isDerivedFrom(&GrandParent))


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


[PATCH] D56441: [analyzer][CrossTU][NFC] Generalize to external definitions instead of external functions

2019-01-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Hmm, it disappeared after a clean rebuild. I think the problem was that i did 
`make clang` and then ran tests manually, instead of `make`, so the tool was 
not rebuilt and was only present under its old name. Because the tool does get 
rebuilt under `make check-clang-analysis`, i guess i was just doing an 
unsupported thing.

Sry for distraction, pls nvm :)


Repository:
  rL LLVM

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

https://reviews.llvm.org/D56441



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


[PATCH] D56532: [clang-tidy] Add the abseil-duration-conversion-cast check

2019-01-10 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 181204.
hwright marked an inline comment as done.
hwright added a comment.

Run `clang-format`


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

https://reviews.llvm.org/D56532

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/DurationComparisonCheck.cpp
  clang-tidy/abseil/DurationConversionCastCheck.cpp
  clang-tidy/abseil/DurationConversionCastCheck.h
  clang-tidy/abseil/DurationRewriter.cpp
  clang-tidy/abseil/DurationRewriter.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-duration-conversion-cast.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-duration-conversion-cast.cpp

Index: test/clang-tidy/abseil-duration-conversion-cast.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-duration-conversion-cast.cpp
@@ -0,0 +1,84 @@
+// RUN: %check_clang_tidy %s abseil-duration-conversion-cast %t -- -- -I%S/Inputs
+
+#include "absl/time/time.h"
+
+void f() {
+  absl::Duration d1;
+  double x;
+  int i;
+
+  i = static_cast(absl::ToDoubleHours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Hours(d1);
+  x = static_cast(absl::ToInt64Hours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleHours(d1);
+  i = static_cast(absl::ToDoubleMinutes(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Minutes(d1);
+  x = static_cast(absl::ToInt64Minutes(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMinutes(d1);
+  i = static_cast(absl::ToDoubleSeconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Seconds(d1);
+  x = static_cast(absl::ToInt64Seconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleSeconds(d1);
+  i = static_cast(absl::ToDoubleMilliseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Milliseconds(d1);
+  x = static_cast(absl::ToInt64Milliseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMilliseconds(d1);
+  i = static_cast(absl::ToDoubleMicroseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Microseconds(d1);
+  x = static_cast(absl::ToInt64Microseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMicroseconds(d1);
+  i = static_cast(absl::ToDoubleNanoseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Nanoseconds(d1);
+  x = static_cast(absl::ToInt64Nanoseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleNanoseconds(d1);
+
+  // Functional-style casts
+  i = int(absl::ToDoubleHours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Hours(d1);
+  x = float(absl::ToInt64Microseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMicroseconds(d1);
+
+  // C-style casts
+  i = (int) absl::ToDoubleHours(d1);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Hours(d1);
+  x = (float) absl::ToInt64Microseconds(d1);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMicroseconds(d1);
+
+  // Macro handling
+  // We want to transform things in macro arguments
+#define EXTERNAL(x) (x) + 5
+  i = EXTERNAL(static_cast(absl::ToDoubleSeconds(d1)));
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: EXTERNAL(absl::ToInt64Seconds(d1));
+#undef EXTERNAL
+
+  // We don't want to transform this which get split across macro boundaries
+#define SPLIT(x) static_cast((x))

[PATCH] D3853: Begin implementing Plan 9 C extensions.

2019-01-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

If someone wants to pick this up and run with it, this patch is fine as a 
starting point (though will need to be rebased).


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

https://reviews.llvm.org/D3853



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


[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in LLVM

2019-01-10 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Thanks for all the work that went into this patch, both initially and rebasing!




Comment at: lib/AST/Stmt.cpp:465
+  const LabelDecl *LD = getLabelExpr(i)->getLabel();
+  return LD->getName();
+}

These 2 statements can probably be condensed into one.
```
return getLabelExpr(i)->getLabel()->getName();
```



Comment at: lib/CodeGen/CGStmt.cpp:2182
+}
+  }
+

If this new block was moved closer to the new one on L2227, I assume they could 
be combined and possibly `IsGCCAsmGoto` be removed?  The code currently in 
between doesn't appear at first site to depend on info from this block, though 
maybe I may be missing it.



Comment at: lib/Parse/ParseStmtAsm.cpp:830-858
+  if (AteExtraColon || Tok.is(tok::colon)) {
+if (AteExtraColon)
+  AteExtraColon = false;
+else
+  ConsumeToken();
+
+if (!AteExtraColon && Tok.isNot(tok::identifier)) {

```
if (x || y) {
  if (x) foo();
  else bar();
  if (!x && ...) baz();
  if (!x && ...) quux();
```
is maybe more readable as:
```
if (x) foo();
else if (y)
  bar();
  baz();
  quux();
```



Comment at: test/CodeGen/asm.c:271
+  // CHECK: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", 
"r,X,X,~{dirflag},~{fpsr},~{flags}"(i32 %0, i8* blockaddress(@t32, 
%label_true), i8* blockaddress(@t32, %loop)) #1
+return 0;
+loop:

extra indentation?



Comment at: test/Parser/asm.c:22-37
+// expected-error@+1 {{expected ')'}}
+asm ("mov %[e], %[e]" : : [e] "rm" (*e)::a)
+// expected-error@+1 {{expected ':'}}
+asm goto ("decl %0; jnz %l[a]" :"=r"(x): "m"(x) : "memory" : a);
+// expected-error@+1 {{expected identifie}}
+asm goto ("decl %0;" :: "m"(x) : "memory" : );
+// expected-error@+1 {{expected ':'}} 

Extra indentation intentional?



Comment at: test/Parser/asm.cpp:14-29
+// expected-error@+1 {{expected ')'}}
+asm ("mov %[e], %[e]" : : [e] "rm" (*e)::a)
+// expected-error@+1  {{expected ':'}}
+asm goto ("decl %0; jnz %l[a]" :"=r"(x): "m"(x) : "memory" : a);
+// expected-error@+1 {{expected identifie}}
+asm goto ("decl %0;" :: "m"(x) : "memory" : );
+// expected-error@+1  {{expected ':'}}

ditto


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

https://reviews.llvm.org/D56571



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


[PATCH] D56509: [AST] Remove ASTContext from getThisType (NFC)

2019-01-10 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Great, thanks for  the review!


Repository:
  rC Clang

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

https://reviews.llvm.org/D56509



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


RE: [PATCH] D56571: [RFC prototype] Implementation of asm-goto support in LLVM

2019-01-10 Thread Yu, Jennifer via cfe-commits
Syntax for asm goto:
Syntax:
  asm [volatile] goto ( AssemblerTemplate
  :
  : InputOperands
  : Clobbers
  : GotoLabels)

Only input is allowed.  Output is not allowed
Thanks.
Jennifer

-Original Message-
From: Eli Friedman via Phabricator [mailto:revi...@reviews.llvm.org] 
Sent: Thursday, January 10, 2019 5:58 PM
To: craig.top...@gmail.com; Keane, Erich ; 
ndesaulni...@google.com; chandl...@gmail.com; Yu, Jennifer 
; syaghm...@apple.com
Cc: efrie...@codeaurora.org; srhi...@google.com; era...@google.com; 
cfe-commits@lists.llvm.org
Subject: [PATCH] D56571: [RFC prototype] Implementation of asm-goto support in 
LLVM

efriedma added a comment.

Missing changes to lib/Analysis/CFG.cpp.




Comment at: lib/Sema/SemaStmtAsm.cpp:470
+if (NS->isGCCAsmGoto() &&
+Exprs[ConstraintIdx]->getStmtClass() == Stmt::AddrLabelExprClass)
+  break;

This looks suspicious; an AddrLabelExpr could be an input or output, e.g. 
`"r"(&&foo)`.


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

https://reviews.llvm.org/D56571



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


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

2019-01-10 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Jan 10 20:57:34 2019
New Revision: 350917

URL: http://llvm.org/viewvc/llvm-project?rev=350917&view=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&r1=350916&r2=350917&view=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 &Previous);
   void CheckVariableDeclarationType(VarDecl *NewVD);
   bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit,
- Expr *Init);
+ Expr *&Init);
   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 *&Init);
 
   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&r1=350916&r2=350917&view=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 *&Init) {
   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 *&Init) {
   QualType DeducedType = deduceVarTypeFromInitializer(
   VDecl, VDecl->getDeclName(), VDecl->getType(), 
VDecl->getTypeSourceInfo(),
   VDecl->getSourceRange(), DirectInit, Init);
@@ -11451,8 +11452,9 @@ void Sema::ActOnUninitializedDecl(Decl *
   return;
 }
 
+Expr *TmpInit = nullptr;
 if (Type->isUndeducedType() &&
-DeduceVariableDeclarationType(Var, false, nullptr))
+DeduceVariableDeclarationType(Var, false, TmpInit))
   return;
 
 // C++11 [class.static.data]p3: A static data member can be declared with

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=350917&r1=350916&r2=350917&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Jan 10 20:57:34 2019
@@ -1865,12 +1865,11 @@ Sema::BuildCXXNew(SourceRange Range, boo
 if (Braced && !getLangOpts().CPlusPlus17)
   Diag(Initializer->getBeginLoc(), diag::ext_auto_new_list_init)
   << AllocType << TypeRange;
-Expr *Deduce = Inits[0];
 QualType DeducedType;
-if (DeduceAutoType(AllocTypeInfo, Deduce, DeducedType) == DAR_Failed)
+if (DeduceAutoType(AllocTypeInfo, Inits[0], DeducedType) == DAR_Failed)
   return ExprEr

r350920 - [Sema] Make canPassInRegisters return true if the CXXRecordDecl passed

2019-01-10 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Jan 10 23:06:38 2019
New Revision: 350920

URL: http://llvm.org/viewvc/llvm-project?rev=350920&view=rev
Log:
[Sema] Make canPassInRegisters return true if the CXXRecordDecl passed
to it is a trivial_abi class.

A class that has all of its copy and move constructors deleted can still
be passed or returned in registers if the class is annotated with
trivial_abi.

This fixes PR39683.

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/trivial_abi.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=350920&r1=350919&r2=350920&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Jan 10 23:06:38 2019
@@ -5886,6 +5886,9 @@ static bool canPassInRegisters(Sema &S,
   if (D->isDependentType() || D->isInvalidDecl())
 return false;
 
+  if (D->hasAttr())
+return true;
+
   // Clang <= 4 used the pre-C++11 rule, which ignores move operations.
   // The PS4 platform ABI follows the behavior of Clang 3.2.
   if (CCK == TargetInfo::CCK_ClangABI4OrPS4)

Modified: cfe/trunk/test/CodeGenCXX/trivial_abi.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/trivial_abi.cpp?rev=350920&r1=350919&r2=350920&view=diff
==
--- cfe/trunk/test/CodeGenCXX/trivial_abi.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/trivial_abi.cpp Thu Jan 10 23:06:38 2019
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fcxx-exceptions 
-fexceptions -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fcxx-exceptions 
-fexceptions -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++17 -fcxx-exceptions 
-fexceptions -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++17 -fcxx-exceptions 
-fexceptions -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s
 
 // CHECK: %[[STRUCT_SMALL:.*]] = type { i32* }
 // CHECK: %[[STRUCT_LARGE:.*]] = type { i32*, [128 x i32] }
@@ -43,6 +43,13 @@ struct HasNonTrivial {
   NonTrivial m;
 };
 
+struct __attribute__((trivial_abi)) CopyMoveDeleted {
+  CopyMoveDeleted(int);
+  CopyMoveDeleted(const CopyMoveDeleted &) = delete;
+  CopyMoveDeleted(CopyMoveDeleted &&) = delete;
+  int a;
+};
+
 // CHECK: define void @_Z14testParamSmall5Small(i64 %[[A_COERCE:.*]])
 // CHECK: %[[A:.*]] = alloca %[[STRUCT_SMALL]], align 8
 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], 
%[[STRUCT_SMALL]]* %[[A]], i32 0, i32 0
@@ -237,3 +244,11 @@ void calleeExceptionLarge(Large, Large);
 void testExceptionLarge() {
   calleeExceptionLarge(Large(), Large());
 }
+
+// A class with deleted copy and move constructors can still be passed or
+// returned in registers if the class is annotated with trivial_abi.
+
+// CHECK: define i64 @_Z19testCopyMoveDeletedi(i32 %
+CopyMoveDeleted testCopyMoveDeleted(int a) {
+  return a;
+}


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


Re: r350920 - [Sema] Make canPassInRegisters return true if the CXXRecordDecl passed

2019-01-10 Thread Richard Smith via cfe-commits
This is an ABI break (theoretically), but due to its nature I'm not too
concerned.

Please update the documentation for the attribute to describe these new
semantics, though: the documentation currently says that we're just
treating certain special members as if they were trivial when determining
whether we can pass in registers, and that's not true any more, because the
ABI says that classes with only deleted copy and move ctors is never passed
in registers regardless of triviality.

On Thu, 10 Jan 2019, 23:10 Akira Hatanaka via cfe-commits <
cfe-commits@lists.llvm.org wrote:

> Author: ahatanak
> Date: Thu Jan 10 23:06:38 2019
> New Revision: 350920
>
> URL: http://llvm.org/viewvc/llvm-project?rev=350920&view=rev
> Log:
> [Sema] Make canPassInRegisters return true if the CXXRecordDecl passed
> to it is a trivial_abi class.
>
> A class that has all of its copy and move constructors deleted can still
> be passed or returned in registers if the class is annotated with
> trivial_abi.
>
> This fixes PR39683.
>
> Modified:
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/test/CodeGenCXX/trivial_abi.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=350920&r1=350919&r2=350920&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Jan 10 23:06:38 2019
> @@ -5886,6 +5886,9 @@ static bool canPassInRegisters(Sema &S,
>if (D->isDependentType() || D->isInvalidDecl())
>  return false;
>
> +  if (D->hasAttr())
> +return true;
> +
>// Clang <= 4 used the pre-C++11 rule, which ignores move operations.
>// The PS4 platform ABI follows the behavior of Clang 3.2.
>if (CCK == TargetInfo::CCK_ClangABI4OrPS4)
>
> Modified: cfe/trunk/test/CodeGenCXX/trivial_abi.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/trivial_abi.cpp?rev=350920&r1=350919&r2=350920&view=diff
>
> ==
> --- cfe/trunk/test/CodeGenCXX/trivial_abi.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/trivial_abi.cpp Thu Jan 10 23:06:38 2019
> @@ -1,5 +1,5 @@
> -// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fcxx-exceptions
> -fexceptions -emit-llvm -o - %s | FileCheck %s
> -// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fcxx-exceptions
> -fexceptions -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s
> +// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++17 -fcxx-exceptions
> -fexceptions -emit-llvm -o - %s | FileCheck %s
> +// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++17 -fcxx-exceptions
> -fexceptions -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s
>
>  // CHECK: %[[STRUCT_SMALL:.*]] = type { i32* }
>  // CHECK: %[[STRUCT_LARGE:.*]] = type { i32*, [128 x i32] }
> @@ -43,6 +43,13 @@ struct HasNonTrivial {
>NonTrivial m;
>  };
>
> +struct __attribute__((trivial_abi)) CopyMoveDeleted {
> +  CopyMoveDeleted(int);
> +  CopyMoveDeleted(const CopyMoveDeleted &) = delete;
> +  CopyMoveDeleted(CopyMoveDeleted &&) = delete;
> +  int a;
> +};
> +
>  // CHECK: define void @_Z14testParamSmall5Small(i64 %[[A_COERCE:.*]])
>  // CHECK: %[[A:.*]] = alloca %[[STRUCT_SMALL]], align 8
>  // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]],
> %[[STRUCT_SMALL]]* %[[A]], i32 0, i32 0
> @@ -237,3 +244,11 @@ void calleeExceptionLarge(Large, Large);
>  void testExceptionLarge() {
>calleeExceptionLarge(Large(), Large());
>  }
> +
> +// A class with deleted copy and move constructors can still be passed or
> +// returned in registers if the class is annotated with trivial_abi.
> +
> +// CHECK: define i64 @_Z19testCopyMoveDeletedi(i32 %
> +CopyMoveDeleted testCopyMoveDeleted(int a) {
> +  return a;
> +}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56554: [ELF] Add '-z nognustack' opt to suppress emitting PT_GNU_STACK

2019-01-10 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

@ruiu, what if one of the systems changes defaults (e.g. due to Hardening) and 
starts defaulting to noexecstack? In that case we'd want `-z execstack' to 
actually emit PT_GNU_STACK, and I don't think we really are able to 100% detect 
the default in clang. I'd really see this as a trinary option: emit RW, emit 
RWX or not emit at all. I don't think it's a good idea to make linker rely on 
implicit assumptions or hidden guesses that could easily confuse user as to 
what's happening and why.


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D56554



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


[PATCH] D54071: [Bug 39548][Clang] PGO bootstrap fails with python3: errors in perf-helper.py

2019-01-10 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@Romain-Geissler-1A sure thing. Can you rebase your patch on master first?


Repository:
  rC Clang

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

https://reviews.llvm.org/D54071



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


[PATCH] D54996: [libclang] Fix clang_Cursor_isAnonymous

2019-01-10 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 181005.
yvvan added a comment.

Replace the absolute path with {{.*}} to be independent from the machine.


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

https://reviews.llvm.org/D54996

Files:
  test/Index/print-type.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CXType.cpp


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -1229,11 +1229,15 @@
   if (!clang_isDeclaration(C.kind))
 return 0;
   const Decl *D = cxcursor::getCursorDecl(C);
-  if (const RecordDecl *FD = dyn_cast_or_null(D))
-return FD->isAnonymousStructOrUnion();
+  if (const NamespaceDecl *ND = dyn_cast_or_null(D)) {
+return ND->isAnonymousNamespace();
+  } else if (const TagDecl *TD = dyn_cast_or_null(D)) {
+return TD->getTypedefNameForAnonDecl() == nullptr &&
+   TD->getIdentifier() == nullptr;
+  }
+
   return 0;
 }
-
 CXType clang_Type_getNamedType(CXType CT){
   QualType T = GetQualType(CT);
   const Type *TP = T.getTypePtrOrNull();
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1654,16 +1654,17 @@
 if (numFields != 0) {
   printf(" [nbFields=%d]", numFields);
 }
-/* Print if it is an anonymous record. */
-{
-  unsigned isAnon = clang_Cursor_isAnonymous(cursor);
-  if (isAnon != 0) {
-printf(" [isAnon=%d]", isAnon);
-  }
-}
   }
 }
 
+/* Print if it is an anonymous record or namespace. */
+{
+  unsigned isAnon = clang_Cursor_isAnonymous(cursor);
+  if (isAnon != 0) {
+printf(" [isAnon=%d]", isAnon);
+  }
+}
+
 printf("\n");
   }
   return CXChildVisit_Recurse;
Index: test/Index/print-type.cpp
===
--- test/Index/print-type.cpp
+++ test/Index/print-type.cpp
@@ -79,6 +79,17 @@
 
 outer::Foo parameter;
 outer::inner::Bar construct(¶meter);
+
+class X {
+  struct { int a; };
+  class { public: int b; };
+  union { int c; int d;};
+  enum { Test };
+};
+
+namespace {
+  int a;
+}
 // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
 // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
@@ -188,3 +199,8 @@
 // CHECK: TypeAliasDecl=baz:76:7 (Definition) [type=baz] [typekind=Typedef] 
[templateargs/1= [type=A] [typekind=Unexposed]] [canonicaltype=A] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=void] 
[typekind=Void]] [isPOD=0]
 // CHECK: VarDecl=autoTemplPointer:78:6 (Definition) 
[type=Specialization &> *] [typekind=Auto] 
[canonicaltype=Specialization &> *] 
[canonicaltypekind=Pointer] [isPOD=1] 
[pointeetype=Specialization &>] [pointeekind=Record]
 // CHECK: CallExpr=Bar:17:3 [type=outer::inner::Bar] [typekind=Elaborated] 
[canonicaltype=outer::inner::Bar] [canonicaltypekind=Record] [args= 
[outer::Foo *] [Pointer]] [isPOD=0] [nbFields=3]
+// CHECK: StructDecl=:84:3 (Definition) [type=X::(anonymous struct at 
{{.*}}print-type.cpp:84:3)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1]
+// CHECK: ClassDecl=:85:3 (Definition) [type=X::(anonymous class at 
{{.*}}print-type.cpp:85:3)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1]
+// CHECK: UnionDecl=:86:3 (Definition) [type=X::(anonymous union at 
{{.*}}print-type.cpp:86:3)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1]
+// CHECK: EnumDecl=:87:3 (Definition) [type=X::(anonymous enum at 
{{.*}}print-type.cpp:87:3)] [typekind=Enum] [isPOD=1] [isAnon=1]
+// CHECK: Namespace=:90:11 (Definition) [type=] [typekind=Invalid] [isPOD=0] 
[isAnon=1]


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -1229,11 +1229,15 @@
   if (!clang_isDeclaration(C.kind))
 return 0;
   const Decl *D = cxcursor::getCursorDecl(C);
-  if (const RecordDecl *FD = dyn_cast_or_null(D))
-return FD->isAnonymousStructOrUnion();
+  if (const NamespaceDecl *ND = dyn_cast_or_null(D)) {
+return ND->isAnonymousNamespace();
+  } else if (const TagDecl *TD = dyn_cast_or_null(D)) {
+return TD->getTypedefNameForAnonDecl() == nullptr &&
+   TD->getIdentifier() == nullptr;
+  }
+
   return 0;
 }
-
 CXType clang_Type_getNamedType(CXType CT){
   QualType T = GetQualType(CT);
   const Type *TP = T.getTypePtrOrNull();
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1654,16 +1654,17 @@
 if (numFields != 0) {
   printf(" [nbFields=%d]", numFields);
 }
-/* Pri

[clang-tools-extra] r350803 - [clangd] Don't store completion info if the symbol is not used for code completion.

2019-01-10 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Jan 10 01:22:40 2019
New Revision: 350803

URL: http://llvm.org/viewvc/llvm-project?rev=350803&view=rev
Log:
[clangd] Don't store completion info if the symbol is not used for code 
completion.

Summary:
This would save us some memory and disk space:
  - Dex usage (261 MB vs 266 MB)
  - Disk (75 MB vs 76 MB)

It would save more when we index the main file symbol D55185.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: nridge, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/index/Index.h
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=350803&r1=350802&r2=350803&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Thu Jan 10 01:22:40 2019
@@ -185,19 +185,23 @@ struct Symbol {
   SymbolOrigin Origin = SymbolOrigin::Unknown;
   /// A brief description of the symbol that can be appended in the completion
   /// candidate list. For example, "(X x, Y y) const" is a function signature.
+  /// Only set when the symbol is indexed for completion.
   llvm::StringRef Signature;
   /// What to insert when completing this symbol, after the symbol name.
   /// This is in LSP snippet syntax (e.g. "({$0})" for a no-args function).
   /// (When snippets are disabled, the symbol name alone is used).
+  /// Only set when the symbol is indexed for completion.
   llvm::StringRef CompletionSnippetSuffix;
   /// Documentation including comment for the symbol declaration.
   llvm::StringRef Documentation;
   /// Type when this symbol is used in an expression. (Short display form).
   /// e.g. return type of a function, or type of a variable.
+  /// Only set when the symbol is indexed for completion.
   llvm::StringRef ReturnType;
 
   /// Raw representation of the OpaqueType of the symbol, used for scoring
   /// purposes.
+  /// Only set when the symbol is indexed for completion.
   llvm::StringRef Type;
 
   struct IncludeHeaderWithReferences {
@@ -223,12 +227,15 @@ struct Symbol {
   ///   - If we haven't seen a definition, this covers all declarations.
   ///   - If we have seen a definition, this covers declarations visible from
   ///   any definition.
+  /// Only set when the symbol is indexed for completion.
   llvm::SmallVector IncludeHeaders;
 
   enum SymbolFlag : uint8_t {
 None = 0,
 /// Whether or not this symbol is meant to be used for the code completion.
 /// See also isIndexedForCodeCompletion().
+/// Note that we don't store completion information (signature, snippet,
+/// type, inclues) if the symbol is not indexed for code completion.
 IndexedForCodeCompletion = 1 << 0,
 /// Indicates if the symbol is deprecated.
 Deprecated = 1 << 1,

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=350803&r1=350802&r2=350803&view=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Thu Jan 10 
01:22:40 2019
@@ -530,6 +530,10 @@ const Symbol *SymbolCollector::addDeclar
   getTokenLocation(Loc, SM, Opts, ASTCtx->getLangOpts(), FileURI))
 S.CanonicalDeclaration = *DeclLoc;
 
+  S.Origin = Opts.Origin;
+  if (ND.getAvailability() == AR_Deprecated)
+S.Flags |= Symbol::Deprecated;
+
   // Add completion info.
   // FIXME: we may want to choose a different redecl, or combine from several.
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
@@ -539,13 +543,28 @@ const Symbol *SymbolCollector::addDeclar
   *ASTCtx, *PP, CodeCompletionContext::CCC_Symbol, *CompletionAllocator,
   *CompletionTUInfo,
   /*IncludeBriefComments*/ false);
-  std::string Signature;
-  std::string SnippetSuffix;
-  getSignature(*CCS, &Signature, &SnippetSuffix);
   std::string Documentation =
   formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
   /*CommentsFromHeaders=*/true));
+  // For symbols not indexed for completion (class members), we also store 
their
+  // docs in the index, because Sema doesn't load the docs from the preamble, 
we
+  // rely on the index to get the docs.
+  // FIXME: this can be optimized by only storing the docs in dynamic index --
+  // dynamic index should index these symbols when Sema completes a member
+  // completion.
+  S.Documentation = Documentation;
+  if (!(S.Flags & Symbol::I

[PATCH] D56314: [clangd] Don't store completion info if the symbol is not used for code completion.

2019-01-10 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350803: [clangd] Don't store completion info if the 
symbol is not used for code… (authored by hokein, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56314

Files:
  clang-tools-extra/trunk/clangd/index/Index.h
  clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
  clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp

Index: clang-tools-extra/trunk/clangd/index/Index.h
===
--- clang-tools-extra/trunk/clangd/index/Index.h
+++ clang-tools-extra/trunk/clangd/index/Index.h
@@ -185,19 +185,23 @@
   SymbolOrigin Origin = SymbolOrigin::Unknown;
   /// A brief description of the symbol that can be appended in the completion
   /// candidate list. For example, "(X x, Y y) const" is a function signature.
+  /// Only set when the symbol is indexed for completion.
   llvm::StringRef Signature;
   /// What to insert when completing this symbol, after the symbol name.
   /// This is in LSP snippet syntax (e.g. "({$0})" for a no-args function).
   /// (When snippets are disabled, the symbol name alone is used).
+  /// Only set when the symbol is indexed for completion.
   llvm::StringRef CompletionSnippetSuffix;
   /// Documentation including comment for the symbol declaration.
   llvm::StringRef Documentation;
   /// Type when this symbol is used in an expression. (Short display form).
   /// e.g. return type of a function, or type of a variable.
+  /// Only set when the symbol is indexed for completion.
   llvm::StringRef ReturnType;
 
   /// Raw representation of the OpaqueType of the symbol, used for scoring
   /// purposes.
+  /// Only set when the symbol is indexed for completion.
   llvm::StringRef Type;
 
   struct IncludeHeaderWithReferences {
@@ -223,12 +227,15 @@
   ///   - If we haven't seen a definition, this covers all declarations.
   ///   - If we have seen a definition, this covers declarations visible from
   ///   any definition.
+  /// Only set when the symbol is indexed for completion.
   llvm::SmallVector IncludeHeaders;
 
   enum SymbolFlag : uint8_t {
 None = 0,
 /// Whether or not this symbol is meant to be used for the code completion.
 /// See also isIndexedForCodeCompletion().
+/// Note that we don't store completion information (signature, snippet,
+/// type, inclues) if the symbol is not indexed for code completion.
 IndexedForCodeCompletion = 1 << 0,
 /// Indicates if the symbol is deprecated.
 Deprecated = 1 << 1,
Index: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
@@ -530,6 +530,10 @@
   getTokenLocation(Loc, SM, Opts, ASTCtx->getLangOpts(), FileURI))
 S.CanonicalDeclaration = *DeclLoc;
 
+  S.Origin = Opts.Origin;
+  if (ND.getAvailability() == AR_Deprecated)
+S.Flags |= Symbol::Deprecated;
+
   // Add completion info.
   // FIXME: we may want to choose a different redecl, or combine from several.
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
@@ -539,13 +543,28 @@
   *ASTCtx, *PP, CodeCompletionContext::CCC_Symbol, *CompletionAllocator,
   *CompletionTUInfo,
   /*IncludeBriefComments*/ false);
-  std::string Signature;
-  std::string SnippetSuffix;
-  getSignature(*CCS, &Signature, &SnippetSuffix);
   std::string Documentation =
   formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
   /*CommentsFromHeaders=*/true));
+  // For symbols not indexed for completion (class members), we also store their
+  // docs in the index, because Sema doesn't load the docs from the preamble, we
+  // rely on the index to get the docs.
+  // FIXME: this can be optimized by only storing the docs in dynamic index --
+  // dynamic index should index these symbols when Sema completes a member
+  // completion.
+  S.Documentation = Documentation;
+  if (!(S.Flags & Symbol::IndexedForCodeCompletion)) {
+Symbols.insert(S);
+return Symbols.find(S.ID);
+  }
+
+  std::string Signature;
+  std::string SnippetSuffix;
+  getSignature(*CCS, &Signature, &SnippetSuffix);
+  S.Signature = Signature;
+  S.CompletionSnippetSuffix = SnippetSuffix;
   std::string ReturnType = getReturnType(*CCS);
+  S.ReturnType = ReturnType;
 
   std::string Include;
   if (Opts.CollectIncludePath && shouldCollectIncludePath(S.SymInfo.Kind)) {
@@ -555,10 +574,6 @@
 QName, SM, SM.getExpansionLoc(ND.getLocation()), Opts))
   Include = std::move(*Header);
   }
-  S.Signature = Signature;
-  S.CompletionSnippetSuffix = SnippetSuffix;
-  S.Documentation = Documentation;
-  S.Return

r350805 - [libclang] Fix clang_Cursor_isAnonymous

2019-01-10 Thread Ivan Donchevskii via cfe-commits
Author: yvvan
Date: Thu Jan 10 01:34:44 2019
New Revision: 350805

URL: http://llvm.org/viewvc/llvm-project?rev=350805&view=rev
Log:
[libclang] Fix clang_Cursor_isAnonymous

Use the same logic as in TypePrinter::printTag to determine that the tag is 
anonymous and the separate check for namespaces.

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

Modified:
cfe/trunk/test/Index/print-type.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/test/Index/print-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type.cpp?rev=350805&r1=350804&r2=350805&view=diff
==
--- cfe/trunk/test/Index/print-type.cpp (original)
+++ cfe/trunk/test/Index/print-type.cpp Thu Jan 10 01:34:44 2019
@@ -79,6 +79,17 @@ auto autoTemplPointer = &autoTemplRefPar
 
 outer::Foo parameter;
 outer::inner::Bar construct(¶meter);
+
+class X {
+  struct { int a; };
+  class { public: int b; };
+  union { int c; int d;};
+  enum { Test };
+};
+
+namespace {
+  int a;
+}
 // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
 // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
@@ -188,3 +199,8 @@ outer::inner::Bar construct(¶meter);
 // CHECK: TypeAliasDecl=baz:76:7 (Definition) [type=baz] [typekind=Typedef] 
[templateargs/1= [type=A] [typekind=Unexposed]] [canonicaltype=A] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=void] 
[typekind=Void]] [isPOD=0]
 // CHECK: VarDecl=autoTemplPointer:78:6 (Definition) 
[type=Specialization &> *] [typekind=Auto] 
[canonicaltype=Specialization &> *] 
[canonicaltypekind=Pointer] [isPOD=1] 
[pointeetype=Specialization &>] [pointeekind=Record]
 // CHECK: CallExpr=Bar:17:3 [type=outer::inner::Bar] [typekind=Elaborated] 
[canonicaltype=outer::inner::Bar] [canonicaltypekind=Record] [args= 
[outer::Foo *] [Pointer]] [isPOD=0] [nbFields=3]
+// CHECK: StructDecl=:84:3 (Definition) [type=X::(anonymous struct at 
{{.*}}print-type.cpp:84:3)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1]
+// CHECK: ClassDecl=:85:3 (Definition) [type=X::(anonymous class at 
{{.*}}print-type.cpp:85:3)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1]
+// CHECK: UnionDecl=:86:3 (Definition) [type=X::(anonymous union at 
{{.*}}print-type.cpp:86:3)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1]
+// CHECK: EnumDecl=:87:3 (Definition) [type=X::(anonymous enum at 
{{.*}}print-type.cpp:87:3)] [typekind=Enum] [isPOD=1] [isAnon=1]
+// CHECK: Namespace=:90:11 (Definition) [type=] [typekind=Invalid] [isPOD=0] 
[isAnon=1]

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=350805&r1=350804&r2=350805&view=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Thu Jan 10 01:34:44 2019
@@ -1654,13 +1654,14 @@ static enum CXChildVisitResult PrintType
 if (numFields != 0) {
   printf(" [nbFields=%d]", numFields);
 }
-/* Print if it is an anonymous record. */
-{
-  unsigned isAnon = clang_Cursor_isAnonymous(cursor);
-  if (isAnon != 0) {
-printf(" [isAnon=%d]", isAnon);
-  }
-}
+  }
+}
+
+/* Print if it is an anonymous record or namespace. */
+{
+  unsigned isAnon = clang_Cursor_isAnonymous(cursor);
+  if (isAnon != 0) {
+printf(" [isAnon=%d]", isAnon);
   }
 }
 

Modified: cfe/trunk/tools/libclang/CXType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=350805&r1=350804&r2=350805&view=diff
==
--- cfe/trunk/tools/libclang/CXType.cpp (original)
+++ cfe/trunk/tools/libclang/CXType.cpp Thu Jan 10 01:34:44 2019
@@ -1229,11 +1229,15 @@ unsigned clang_Cursor_isAnonymous(CXCurs
   if (!clang_isDeclaration(C.kind))
 return 0;
   const Decl *D = cxcursor::getCursorDecl(C);
-  if (const RecordDecl *FD = dyn_cast_or_null(D))
-return FD->isAnonymousStructOrUnion();
+  if (const NamespaceDecl *ND = dyn_cast_or_null(D)) {
+return ND->isAnonymousNamespace();
+  } else if (const TagDecl *TD = dyn_cast_or_null(D)) {
+return TD->getTypedefNameForAnonDecl() == nullptr &&
+   TD->getIdentifier() == nullptr;
+  }
+
   return 0;
 }
-
 CXType clang_Type_getNamedType(CXType CT){
   QualType T = GetQualType(CT);
   const Type *TP = T.getTypePtrOrNull();


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


[PATCH] D54996: [libclang] Fix clang_Cursor_isAnonymous

2019-01-10 Thread Ivan Donchevskii via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350805: [libclang] Fix clang_Cursor_isAnonymous (authored by 
yvvan, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54996?vs=181005&id=181008#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D54996

Files:
  cfe/trunk/test/Index/print-type.cpp
  cfe/trunk/tools/c-index-test/c-index-test.c
  cfe/trunk/tools/libclang/CXType.cpp


Index: cfe/trunk/tools/c-index-test/c-index-test.c
===
--- cfe/trunk/tools/c-index-test/c-index-test.c
+++ cfe/trunk/tools/c-index-test/c-index-test.c
@@ -1654,13 +1654,14 @@
 if (numFields != 0) {
   printf(" [nbFields=%d]", numFields);
 }
-/* Print if it is an anonymous record. */
-{
-  unsigned isAnon = clang_Cursor_isAnonymous(cursor);
-  if (isAnon != 0) {
-printf(" [isAnon=%d]", isAnon);
-  }
-}
+  }
+}
+
+/* Print if it is an anonymous record or namespace. */
+{
+  unsigned isAnon = clang_Cursor_isAnonymous(cursor);
+  if (isAnon != 0) {
+printf(" [isAnon=%d]", isAnon);
   }
 }
 
Index: cfe/trunk/tools/libclang/CXType.cpp
===
--- cfe/trunk/tools/libclang/CXType.cpp
+++ cfe/trunk/tools/libclang/CXType.cpp
@@ -1229,11 +1229,15 @@
   if (!clang_isDeclaration(C.kind))
 return 0;
   const Decl *D = cxcursor::getCursorDecl(C);
-  if (const RecordDecl *FD = dyn_cast_or_null(D))
-return FD->isAnonymousStructOrUnion();
+  if (const NamespaceDecl *ND = dyn_cast_or_null(D)) {
+return ND->isAnonymousNamespace();
+  } else if (const TagDecl *TD = dyn_cast_or_null(D)) {
+return TD->getTypedefNameForAnonDecl() == nullptr &&
+   TD->getIdentifier() == nullptr;
+  }
+
   return 0;
 }
-
 CXType clang_Type_getNamedType(CXType CT){
   QualType T = GetQualType(CT);
   const Type *TP = T.getTypePtrOrNull();
Index: cfe/trunk/test/Index/print-type.cpp
===
--- cfe/trunk/test/Index/print-type.cpp
+++ cfe/trunk/test/Index/print-type.cpp
@@ -79,6 +79,17 @@
 
 outer::Foo parameter;
 outer::inner::Bar construct(¶meter);
+
+class X {
+  struct { int a; };
+  class { public: int b; };
+  union { int c; int d;};
+  enum { Test };
+};
+
+namespace {
+  int a;
+}
 // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
 // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
@@ -188,3 +199,8 @@
 // CHECK: TypeAliasDecl=baz:76:7 (Definition) [type=baz] [typekind=Typedef] 
[templateargs/1= [type=A] [typekind=Unexposed]] [canonicaltype=A] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=void] 
[typekind=Void]] [isPOD=0]
 // CHECK: VarDecl=autoTemplPointer:78:6 (Definition) 
[type=Specialization &> *] [typekind=Auto] 
[canonicaltype=Specialization &> *] 
[canonicaltypekind=Pointer] [isPOD=1] 
[pointeetype=Specialization &>] [pointeekind=Record]
 // CHECK: CallExpr=Bar:17:3 [type=outer::inner::Bar] [typekind=Elaborated] 
[canonicaltype=outer::inner::Bar] [canonicaltypekind=Record] [args= 
[outer::Foo *] [Pointer]] [isPOD=0] [nbFields=3]
+// CHECK: StructDecl=:84:3 (Definition) [type=X::(anonymous struct at 
{{.*}}print-type.cpp:84:3)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1]
+// CHECK: ClassDecl=:85:3 (Definition) [type=X::(anonymous class at 
{{.*}}print-type.cpp:85:3)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1]
+// CHECK: UnionDecl=:86:3 (Definition) [type=X::(anonymous union at 
{{.*}}print-type.cpp:86:3)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1]
+// CHECK: EnumDecl=:87:3 (Definition) [type=X::(anonymous enum at 
{{.*}}print-type.cpp:87:3)] [typekind=Enum] [isPOD=1] [isAnon=1]
+// CHECK: Namespace=:90:11 (Definition) [type=] [typekind=Invalid] [isPOD=0] 
[isAnon=1]


Index: cfe/trunk/tools/c-index-test/c-index-test.c
===
--- cfe/trunk/tools/c-index-test/c-index-test.c
+++ cfe/trunk/tools/c-index-test/c-index-test.c
@@ -1654,13 +1654,14 @@
 if (numFields != 0) {
   printf(" [nbFields=%d]", numFields);
 }
-/* Print if it is an anonymous record. */
-{
-  unsigned isAnon = clang_Cursor_isAnonymous(cursor);
-  if (isAnon != 0) {
-printf(" [isAnon=%d]", isAnon);
-  }
-}
+  }
+}
+
+/* Print if it is an anonymous record or namespace. */
+{
+  unsigned isAnon = clang_Cursor_isAnonymous(cursor);
+  if (isAnon != 0) {
+printf(" [isAnon=%d]", isAnon);
   }
 }
 
Index: cfe/trunk/tools/libclang/CXType.cpp

[PATCH] D56492: [clangd] Add Documentations for member completions.

2019-01-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 181009.
hokein marked 3 inline comments as done.
hokein added a comment.

Address comments.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56492

Files:
  clangd/CodeComplete.cpp
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -729,6 +729,64 @@
 Doc("Doooc"), ReturnType("void";
 }
 
+TEST(CompletionTest, DocumentationFromIndex) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  FS.Files[testPath("foo.h")] = R"cpp(
+  class Foo {
+  public:
+// Doc for foo
+int foo();
+
+// Doc for foo int
+int foo2(int);
+// Doc for foo bool
+int foo2(bool);
+  };
+  )cpp";
+
+  auto File = testPath("bar.cpp");
+  Annotations Test(R"cpp(
+  #include "foo.h"
+  void test() {
+Foo f;
+f.^
+  }
+  )cpp");
+  auto Opts = ClangdServer::optsForTest();
+  {
+// Run code completion without index, verify that we don't get any docs from
+// Sema.
+Opts.BuildDynamicSymbolIndex = false;
+ClangdServer Server(CDB, FS, DiagConsumer, Opts);
+runAddDocument(Server, File, Test.code());
+auto Results = cantFail(runCodeComplete(Server, File, Test.point(), {}));
+EXPECT_THAT(
+Results.Completions,
+Contains((Named("foo"), Kind(CompletionItemKind::Method), Doc("";
+EXPECT_THAT(
+Results.Completions,
+Contains((Named("foo2"), Kind(CompletionItemKind::Method), Doc("";
+  }
+  {
+Opts.BuildDynamicSymbolIndex = true;
+ClangdServer Server(CDB, FS, DiagConsumer, Opts);
+runAddDocument(Server, File, Test.code());
+clangd::CodeCompleteOptions CCOpts;
+CCOpts.BundleOverloads = true;
+auto Results =
+cantFail(runCodeComplete(Server, File, Test.point(), CCOpts));
+EXPECT_THAT(Results.Completions,
+Contains((Named("foo"), Kind(CompletionItemKind::Method),
+  Doc("Doc for foo";
+// No doc for overload bundle.
+EXPECT_THAT(
+Results.Completions,
+Contains((Named("foo2"), Kind(CompletionItemKind::Method), Doc("";
+  }
+}
+
 TEST(CompletionTest, Documentation) {
   auto Results = completions(
   R"cpp(
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -1366,11 +1366,45 @@
 auto Top = mergeResults(Recorder->Results, IndexResults);
 CodeCompleteResult Output;
 
+// Keys are indices into Output vector.
+llvm::DenseMap OutputIndex;
+LookupRequest DocIndexRequest;
 // Convert the results to final form, assembling the expensive strings.
-for (auto &C : Top) {
-  Output.Completions.push_back(toCodeCompletion(C.first));
-  Output.Completions.back().Score = C.second;
+for (size_t I = 0; I < Top.size(); ++I) {
+  const auto& Bundle = Top[I].first;
+  const auto& Scope = Top[I].second;
+  Output.Completions.push_back(toCodeCompletion(Bundle));
+  Output.Completions.back().Score = Scope;
   Output.Completions.back().CompletionTokenRange = TextEditRange;
+
+  if (Opts.IncludeComments &&
+  Output.Completions.back().Documentation.empty()) {
+if (Bundle.size() != 1)
+  continue;
+const auto *SemaR = Bundle.front().SemaResult;
+if (!SemaR)
+  continue;
+if (auto ID =
+getSymbolID(*SemaR, Recorder->CCSema->getSourceManager())) {
+  OutputIndex[I] = *ID;
+  DocIndexRequest.IDs.insert(*ID);
+}
+  }
+}
+// Sema doesn't load docs from the preamble, so we get the docs from the
+// index and assemble them for the final results.
+if (!DocIndexRequest.IDs.empty() && Opts.Index) {
+  llvm::DenseMap FetchedDocs;
+  Opts.Index->lookup(DocIndexRequest, [&](const Symbol &S) {
+if (!S.Documentation.empty())
+  FetchedDocs[S.ID] = S.Documentation;
+  });
+  for (auto IndexAndID : OutputIndex) {
+auto FetchDocsIt = FetchedDocs.find(IndexAndID.second);
+if (FetchDocsIt != FetchedDocs.end())
+  Output.Completions[IndexAndID.first].Documentation =
+  FetchDocsIt->second;
+  }
 }
 Output.HasMore = Incomplete;
 Output.Context = Recorder->CCContext.getKind();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check

2019-01-10 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber updated this revision to Diff 181015.
bernhardmgruber added a comment.

rebased on current master (there was a conflict in the release notes)


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

https://reviews.llvm.org/D56160

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseTrailingReturnCheck.cpp
  clang-tidy/modernize/UseTrailingReturnCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-trailing-return.rst
  test/clang-tidy/modernize-use-trailing-return.cpp

Index: test/clang-tidy/modernize-use-trailing-return.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-trailing-return.cpp
@@ -0,0 +1,269 @@
+// RUN: %check_clang_tidy %s modernize-use-trailing-return %t -- -- --std=c++14
+
+namespace std {
+template 
+class vector;
+
+class string;
+}
+
+//
+// Functions
+//
+
+int f();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f() -> int;{{$}}
+int f(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int) -> int;{{$}}
+int f(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int arg) -> int;{{$}}
+int f(int arg1, int arg2, int arg3);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int arg1, int arg2, int arg3) -> int;{{$}}
+int f(int arg1, int arg2, int arg3, ...);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int arg1, int arg2, int arg3, ...) -> int;{{$}}
+template  int f(T t);
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}template  auto f(T t) -> int;{{$}}
+
+//
+// Functions with formatting
+//
+
+int a1() { return 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a1() -> int { return 42; }{{$}}
+int a2() {
+return 42;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a2() -> int {{{$}}
+int a3()
+{
+return 42;
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a3() -> int{{$}}
+int a4(int   arg   )   ;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a4(int   arg   ) -> int   ;{{$}}
+int a5
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a5{{$}}
+(int arg);
+// CHECK-FIXES: {{^}}(int arg) -> int;{{$}}
+
+//
+// Functions with qualifiers and specifiers
+//
+
+inline int d1(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}inline auto d1(int arg) -> int;{{$}}
+extern "C" int d2(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}extern "C" auto d2(int arg) -> int;{{$}}
+inline int d3(int arg) noexcept(true);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}inline auto d3(int arg) -> int noexcept(true);{{$}}
+inline int d4(int arg) try { } catch(...) { }
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}inline auto d4(int arg) -> int try { } catch(...) { }{{$}}
+
+//
+// Functions in namespaces
+//
+
+namespace N {
+int e1();
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto e1() -> int;{{$}}
+int N::e1() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto N::e1() -> int {}{{$}}
+
+//
+// Functions with complex return types
+//
+
+inline volatile const std::vector e2();
+// CHECK-MESSAGES: :[[@LINE-1]]:48: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}inline auto e2() -> volatile const std::vector;{

[PATCH] D50106: [libc++] Fix tuple assignment from type derived from a tuple-like

2019-01-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

Our constructors still have the same bug,. Are you planning on fixing those as 
well? Doing so will require a metric butt-tonne of overloads.
If you're not planning on fixing the constructors, then can you explain why 
it's better that we're inconsistent?

Otherwises, this patch looks mostly OK. However, it makes a bunch of previously 
lazy SFINAE eager. Here are some tests:
https://gist.github.com/EricWF/88ceadf2bcdeef9f9d268b3a743dcd04

Is there a reason we can't use `__tuple_assignable` anymore?


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D50106



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


[PATCH] D54945: This commit adds a chapter about clang-tidy integrations

2019-01-10 Thread Marina Kalashina via Phabricator via cfe-commits
MarinaKalashina updated this revision to Diff 181018.
MarinaKalashina added a comment.

Extracting 'Getting Involved' and 'Clang-tidy integrations' to separate pages 
linked in See Also.


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

https://reviews.llvm.org/D54945

Files:
  docs/clang-tidy/contribution.rst
  docs/clang-tidy/index.rst
  docs/clang-tidy/integrations.rst

Index: docs/clang-tidy/integrations.rst
===
--- /dev/null
+++ docs/clang-tidy/integrations.rst
@@ -0,0 +1,117 @@
+==
+Clang-tidy IDE/Editor Integrations
+==
+
+.. _Clangd: https://clang.llvm.org/extra/clangd.html
+
+Apart from being a standalone tool, :program:`clang-tidy` is integrated into
+various IDEs, code analyzers, and editors. Besides, it is currently being
+integrated into Clangd_. The following table shows the most
+well-known :program:`clang-tidy` integrations in detail.
+
++--++-+--+-+--+
+|  |Feature   |
++==++=+==+=+==+
+|  **Tool**| On-the-fly inspection  | Check list configuration (GUI)  | Options to checks (GUI)  | Configuration via ``.clang-tidy`` files | Custom clang-tidy binary |
++--++-+--+-+--+
+|A.L.E. for Vim| \+\|   \-\   |   \-\| \-\ |   \+\|
++--++-+--+-+--+
+|Clang Power Tools for Visual Studio   | \-\|   \+\   |   \-\| \+\ |   \-\|
++--++-+--+-+--+
+|Clangd| \+\|   \-\   |   \-\| \-\ |   \-\|
++--++-+--+-+--+
+|CLion IDE | \+\|   \+\   |   \+\| \+\ |   \+\|
++--++-+--+-+--+
+|CodeChecker   | \-\|   \-\   |   \-\| \-\ |   \+\|
++--++-+--+-+--+
+|CPPCheck  | \-\|   \-\   |   \-\| \-\ |   \-\|
++--++-+--+-+--+
+|CPPDepend | \-\|   \-\   |   \-\| \-\ |   \-\|
++--++-+--+-+--+
+|Flycheck for Emacs| \+\|   \-\   |   \-\| \+\ |   \+\|
++--+---

[PATCH] D54945: This commit adds a chapter about clang-tidy integrations

2019-01-10 Thread Marina Kalashina via Phabricator via cfe-commits
MarinaKalashina added a comment.

@alexfh Thank you, please see the updated structure.
@Eugene.Zelenko Done, the only warnings I got were about the table rows width.


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

https://reviews.llvm.org/D54945



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


[PATCH] D56492: [clangd] Add Documentations for member completions.

2019-01-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I think the design should be more thoroughly considered here.

- what are the latency consequences of the extra index lookup in different 
scenarios?
- how does this compare to doing it at LSP resolve time instead?
- if we're going to do the extra lookup, can we make use of ranking signals 
from the index too?




Comment at: clangd/CodeComplete.cpp:1369
 
+// Keys are indices into Output vector.
+llvm::DenseMap OutputIndex;

I don't think we can inline this much logic into `runWithSema()` for each 
feature we add - need to find a clearer way to structure the code.



Comment at: clangd/CodeComplete.cpp:1398
+  llvm::DenseMap FetchedDocs;
+  Opts.Index->lookup(DocIndexRequest, [&](const Symbol &S) {
+if (!S.Documentation.empty())

If we're going to query the index again here, it seems we should do it earlier 
so we can use the results for ranking.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56492



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


[clang-tools-extra] r350814 - [clang-tidy] Fix case of local variables in modernize-use-nodiscard checker

2019-01-10 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Thu Jan 10 03:56:44 2019
New Revision: 350814

URL: http://llvm.org/viewvc/llvm-project?rev=350814&view=rev
Log:
[clang-tidy] Fix case of local variables in modernize-use-nodiscard checker

Summary:
Correct the case of the local variables..

Rational:
I want to be able to run clang-tidy on new clang-tidy checker code prior to 
creating a review (to demonstrate we should dog food our own tools during 
development, not my suggestion but @Eugene.Zelenko)

To this end I am running the following in a script, prior to make a change.

```
tidy:
@for source in $$(git status -suno | grep ".cpp$$" | cut -c4-) ;\
do \
clang-tidy -quiet  $$source -- $(TIDY_FLAGS);\
done

```

I then want to go through the checkers and see which checkers most closely 
match the review style of the reviewers

```
---
Checks:  '
-clang-diagnostic-*,
readability-identifier-naming,
llvm-header-guard
'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: LLVM
CheckOptions:
  - key: readability-identifier-naming.IgnoreFailedSplit
value:   '0'
  - key: readability-identifier-naming.VariableCase
value:   'CamelCase'
  - key: readability-identifier-naming.LocalVariableCase
value:   'CamelCase'
...

```

Unfortunately in doing so, I have identified that my previous review {D55433} 
it violates what looks like to be the convention of local variables being in 
CamelCase.

Sending this small review in the hope it can be corrected.

Patch by MyDeveloperDay.

Reviewers: JonasToth, Eugene.Zelenko

Reviewed By: JonasToth

Subscribers: xazax.hun, Eugene.Zelenko

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.cpp?rev=350814&r1=350813&r2=350814&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.cpp Thu Jan 
10 03:56:44 2019
@@ -92,7 +92,7 @@ void UseNodiscardCheck::registerMatchers
   !getLangOpts().CPlusPlus)
 return;
 
-  auto functionObj =
+  auto FunctionObj =
   cxxRecordDecl(hasAnyName("::std::function", "::boost::function"));
 
   // Find all non-void const methods which have not already been marked to
@@ -107,8 +107,8 @@ void UseNodiscardCheck::registerMatchers
 hasAttr(clang::attr::WarnUnusedResult),
 hasType(isInstantiationDependentType()),
 hasAnyParameter(anyOf(
-parmVarDecl(anyOf(hasType(functionObj),
-  hasType(references(functionObj,
+parmVarDecl(anyOf(hasType(FunctionObj),
+  hasType(references(FunctionObj,
 hasType(isNonConstReferenceOrPointer()),
 hasParameterPack()))
   .bind("no_discard"),
@@ -122,11 +122,11 @@ void UseNodiscardCheck::check(const Matc
   if (Loc.isInvalid() || Loc.isMacroID())
 return;
 
-  SourceLocation retLoc = MatchedDecl->getInnerLocStart();
+  SourceLocation RetLoc = MatchedDecl->getInnerLocStart();
 
   ASTContext &Context = *Result.Context;
 
-  auto Diag = diag(retLoc, "function %0 should be marked " + NoDiscardMacro)
+  auto Diag = diag(RetLoc, "function %0 should be marked " + NoDiscardMacro)
   << MatchedDecl;
 
   // Check for the existence of the keyword being used as the 
``[[nodiscard]]``.
@@ -137,7 +137,7 @@ void UseNodiscardCheck::check(const Matc
   // 1. A const member function which returns a variable which is ignored
   // but performs some external I/O operation and the return value could be
   // ignored.
-  Diag << FixItHint::CreateInsertion(retLoc, NoDiscardMacro + " ");
+  Diag << FixItHint::CreateInsertion(RetLoc, NoDiscardMacro + " ");
 }
 
 } // namespace modernize


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


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-10 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

Just in general, I'd like to add that my experience over the years dealing with 
folks trying to do AST matchers is that the inability to express something is 
much more of a problem than matching too much, simply because the test cases 
people think of are usually small, and when running a transformation on a very 
large codebase, the cost of false negatives is significantly higher than the 
cost of false positive: the cost of a false negative means that you may produce 
something incorrect. The cost of a false positive is that you adapt your 
matcher to exclude the false negative.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56444



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


[PATCH] D56539: [clangd] Drop documentation in static index if symbols are not indexed for completion.

2019-01-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric.

This is a further optimization of r350803, we drop docs in static index for
symbols not being indexed for completion, while keeping the docs in dynamic
index (we rely on dynamic index to get docs for class members).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56539

Files:
  clangd/index/FileIndex.cpp
  clangd/index/IndexAction.cpp
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -202,6 +202,12 @@
 return WrapperFrontendAction::CreateASTConsumer(CI, InFile);
   }
 
+  bool BeginInvocation(CompilerInstance &CI) override {
+// Make the compiler parse all comments.
+CI.getLangOpts().CommentOpts.ParseAllComments = true;
+return WrapperFrontendAction::BeginInvocation(CI);
+  }
+
 private:
   index::IndexingOptions IndexOpts;
   CommentHandler *PragmaHandler;
@@ -639,6 +645,34 @@
   UnorderedElementsAre(QName("Foo"), QName("f1"), QName("f2")));
 }
 
+TEST_F(SymbolCollectorTest, Documentation) {
+  const std::string Header = R"(
+// Doc Foo
+class Foo {
+  // Doc f
+  int f();
+};
+  )";
+  {
+CollectorOpts.StoreAllDocumentation = false;
+runSymbolCollector(Header, /* Main */ "");
+EXPECT_THAT(Symbols, UnorderedElementsAre(
+ AllOf(QName("Foo"), Doc("Doc Foo"),
+   ForCodeCompletion(true)),
+ AllOf(QName("Foo::f"), Doc(""), ReturnType(""),
+   ForCodeCompletion(false;
+  }
+  {
+CollectorOpts.StoreAllDocumentation = true;
+runSymbolCollector(Header, /* Main */ "");
+EXPECT_THAT(Symbols, UnorderedElementsAre(
+ AllOf(QName("Foo"), Doc("Doc Foo"),
+   ForCodeCompletion(true)),
+ AllOf(QName("Foo::f"), Doc("Doc f"),
+   ReturnType(""), ForCodeCompletion(false;
+  }
+}
+
 TEST_F(SymbolCollectorTest, ClassMembers) {
   const std::string Header = R"(
 class Foo {
Index: clangd/index/SymbolCollector.h
===
--- clangd/index/SymbolCollector.h
+++ clangd/index/SymbolCollector.h
@@ -72,6 +72,10 @@
 /// collect macros. For example, `indexTopLevelDecls` will not index any
 /// macro even if this is true.
 bool CollectMacro = false;
+/// If set to true, SymbolCollector will collect doc for all symbols.
+/// Note that documents of symbols being indexed for completion will always
+/// be collected regardless of this option.
+bool StoreAllDocumentation = false;
 /// If this is set, only collect symbols/references from a file if
 /// `FileFilter(SM, FID)` is true. If not set, all files are indexed.
 std::function FileFilter = nullptr;
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -546,18 +546,13 @@
   std::string Documentation =
   formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
   /*CommentsFromHeaders=*/true));
-  // For symbols not indexed for completion (class members), we also store their
-  // docs in the index, because Sema doesn't load the docs from the preamble, we
-  // rely on the index to get the docs.
-  // FIXME: this can be optimized by only storing the docs in dynamic index --
-  // dynamic index should index these symbols when Sema completes a member
-  // completion.
-  S.Documentation = Documentation;
   if (!(S.Flags & Symbol::IndexedForCodeCompletion)) {
+if (Opts.StoreAllDocumentation)
+  S.Documentation = Documentation;
 Symbols.insert(S);
 return Symbols.find(S.ID);
   }
-
+  S.Documentation = Documentation;
   std::string Signature;
   std::string SnippetSuffix;
   getSignature(*CCS, &Signature, &SnippetSuffix);
Index: clangd/index/IndexAction.cpp
===
--- clangd/index/IndexAction.cpp
+++ clangd/index/IndexAction.cpp
@@ -175,6 +175,7 @@
   Opts.CollectIncludePath = true;
   Opts.CountReferences = true;
   Opts.Origin = SymbolOrigin::Static;
+  Opts.StoreAllDocumentation = false;
   if (RefsCallback != nullptr) {
 Opts.RefFilter = RefKind::All;
 Opts.RefsInHeaders = true;
Index: clangd/index/FileIndex.cpp
===
--- clangd/index/FileIndex.cpp
+++ clangd/index/FileIndex.cpp

[PATCH] D56523: Improve a -Wunguarded-availability note

2019-01-10 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a reviewer: jkorous.
jkorous added a comment.

Hi Erik, this looks neat!




Comment at: clang/test/Sema/availability-guard-format.mm:6
 @interface foo
-- (void) method_bar __attribute__((availability(macosx, introduced = 10_12))); 
// expected-note {{'method_bar' has been explicitly marked partial here}}
+- (void) method_bar __attribute__((availability(macosx, introduced = 10_12))); 
// expected-note {{'method_bar' has been marked as being introduced in macOS 
10.12 here, but the deployment target is macOS 10.4.0}}
 @end

I am probably missing something but where is the deployment target value set?


Repository:
  rC Clang

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

https://reviews.llvm.org/D56523



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-01-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56411#1352332 , @rjmccall wrote:

> This patch still doesn't make any sense.  You don't need to do any special 
> validation when passing a function as a template argument.  When Sema 
> instantiates the template definition, it'll rebuild the expressions that 
> refer to the template parameter, which will trigger the normal checking for 
> whether those expressions are illegally referencing a host function from the 
> device, etc.  All you need to do is suppress that checking (whether it 
> happens in a template definition or not) for references from 
> non-potentially-evaluated contexts.


If you look at line 6583 of lib/Sema/SemaTemplate.cpp, you will see clang does 
the check if the function needs overloading resolution. However, clang missed 
the check if the function does not need overloading resolution. That's why I 
need to add the check at line 6593. All the other stuff is just to help make 
this check.

why clang does not do the reference check when there is no overloading 
resolution?

I think in usual cases clang already does that check during template argument 
parsing, so it does not need to do that again at line 6593. Unfortunately, for 
CUDA host/device check, it has to be skipped in template argument parsing and 
deferred to line 6593.


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

https://reviews.llvm.org/D56411



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


[PATCH] D56540: [clangd] Clean the cache of file statuses on vscode-clangd when clangd crashes.

2019-01-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric.

Clear the cached file statuses, otherwise We will leave some garbage texts on
the status bar when clangd crashes.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56540

Files:
  clangd/clients/clangd-vscode/src/extension.ts


Index: clangd/clients/clangd-vscode/src/extension.ts
===
--- clangd/clients/clangd-vscode/src/extension.ts
+++ clangd/clients/clangd-vscode/src/extension.ts
@@ -40,6 +40,11 @@
 this.statusBarItem.show();
 }
 
+clear() {
+this.statuses.clear();
+this.statusBarItem.hide();
+}
+
 dispose() {
 this.statusBarItem.dispose();
 }
@@ -112,9 +117,16 @@
 context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(() => 
{
 status.updateStatus();
 }));
-clangdClient.onReady().then(() => {
-clangdClient.onNotification(
-'textDocument/clangd.fileStatus',
-(fileStatus) => { status.onFileUpdated(fileStatus); });
-})
+clangdClient.onDidChangeState(
+({ newState }) => {
+if (newState == vscodelc.State.Running) {
+// clangd starts or restarts after crash.
+clangdClient.onNotification(
+'textDocument/clangd.fileStatus',
+(fileStatus) => { status.onFileUpdated(fileStatus); });
+} else if (newState == vscodelc.State.Stopped) {
+// Clear all cached statuses when clangd crashes.
+status.clear();
+}
+})
 }


Index: clangd/clients/clangd-vscode/src/extension.ts
===
--- clangd/clients/clangd-vscode/src/extension.ts
+++ clangd/clients/clangd-vscode/src/extension.ts
@@ -40,6 +40,11 @@
 this.statusBarItem.show();
 }
 
+clear() {
+this.statuses.clear();
+this.statusBarItem.hide();
+}
+
 dispose() {
 this.statusBarItem.dispose();
 }
@@ -112,9 +117,16 @@
 context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(() => {
 status.updateStatus();
 }));
-clangdClient.onReady().then(() => {
-clangdClient.onNotification(
-'textDocument/clangd.fileStatus',
-(fileStatus) => { status.onFileUpdated(fileStatus); });
-})
+clangdClient.onDidChangeState(
+({ newState }) => {
+if (newState == vscodelc.State.Running) {
+// clangd starts or restarts after crash.
+clangdClient.onNotification(
+'textDocument/clangd.fileStatus',
+(fileStatus) => { status.onFileUpdated(fileStatus); });
+} else if (newState == vscodelc.State.Stopped) {
+// Clear all cached statuses when clangd crashes.
+status.clear();
+}
+})
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r350817 - Correct the spelling of helpURI to helpUri.

2019-01-10 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Jan 10 05:19:48 2019
New Revision: 350817

URL: http://llvm.org/viewvc/llvm-project?rev=350817&view=rev
Log:
Correct the spelling of helpURI to helpUri.

JSON is case sensitive and the SARIF spec uses the corrected spelling.

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

cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp?rev=350817&r1=350816&r2=350817&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp Thu Jan 10 05:19:48 
2019
@@ -285,7 +285,7 @@ static json::Object createRule(const Pat
 
   std::string RuleURI = getRuleHelpURIStr(CheckName);
   if (!RuleURI.empty())
-Ret["helpURI"] = RuleURI;
+Ret["helpUri"] = RuleURI;
 
   return Ret;
 }

Modified: 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif?rev=350817&r1=350816&r2=350817&view=diff
==
--- 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
 (original)
+++ 
cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
 Thu Jan 10 05:19:48 2019
@@ -29,7 +29,7 @@
 "fullDescription": {
   "text": "Check for logical errors for function calls and 
Objective-C message expressions (e.g., uninitialized arguments, null function 
pointers)"
 },
-"helpURI": 
"https://clang-analyzer.llvm.org/available_checks.html#core.CallAndMessage";,
+"helpUri": 
"https://clang-analyzer.llvm.org/available_checks.html#core.CallAndMessage";,
 "id": "core.CallAndMessage",
 "name": {
   "text": "core.CallAndMessage"
@@ -39,7 +39,7 @@
 "fullDescription": {
   "text": "Check for division by zero"
 },
-"helpURI": 
"https://clang-analyzer.llvm.org/available_checks.html#core.DivideZero";,
+"helpUri": 
"https://clang-analyzer.llvm.org/available_checks.html#core.DivideZero";,
 "id": "core.DivideZero",
 "name": {
   "text": "core.DivideZero"


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


[PATCH] D56509: [AST] Remove ASTContext from getThisType (NFC)

2019-01-10 Thread Mikael Nilsson via Phabricator via cfe-commits
mikael accepted this revision.
mikael added a comment.
This revision is now accepted and ready to land.

The changes looks good to me.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56509



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


[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/URI.h:131
+/// Resolves URI to file paths with cache.
+class URIToFileCache {
+public:

Maybe move it into the `Backgroud.cpp`, e.g. as a private member of 
`BackoundIndex`?
We don't have other use-case for it to the date and it doesn't really good like 
a good public API at this point, i.e. lacking docs on what it does and why it's 
useful, which are useful if we move it into a public header.



Comment at: clangd/index/Background.cpp:312
+  // Skip if file is already up to date.
+  auto DigestIt = IndexedFileDigests.try_emplace(Path);
+  if (!DigestIt.second && DigestIt.first->second == Hash)

kadircet wrote:
> ilya-biryukov wrote:
> > We still update digests and symbols non-atomically in that case. Could we 
> > do both under the same lock, similar to how it's done in `loadShards`?
> Moved update to the end of the loop, but now we might perform unnecessary 
> work for building {symbol,ref}slabs for files that are already up-to-date. It 
> shouldn't be too much of an issue, as a solution we can lock at the entrance 
> and only check if the file was up-to-date, than we update at the exit. Or we 
> can keep a snapshot.
LG, thanks. I don't think this extra work should pop up in the profiler, so 
we're good.



Comment at: clangd/index/Background.cpp:311
+ "Trying to update symbols for a file that hasn't been indexed");
+  // If we this is not the latest version of the file just skip.
+  if (LatestFileDigests[Path] != Hash)

NIT: s/we this/this/



Comment at: clangd/index/Background.cpp:312
+  // If we this is not the latest version of the file just skip.
+  if (LatestFileDigests[Path] != Hash)
+continue;

An alternative strategy is to also update if the `IndexedFileDigests` does not 
contain a value.
That would ensure we populate **some** version of all files as fast as 
possible, but only update for the latest version. To me personally this looks 
like a reasonable right trade-off (and would require updating just a few lines 
of code)



Comment at: clangd/index/Background.cpp:319
+  DigestIt.first->second = Hash;
+  vlog("Update symbols in {0}", Path);
+  IndexedSymbols.update(Path, std::move(SS), std::move(RS));

This might be too verbose even for `vlog()`, i.e. this would produce thousands 
of messages for each TU. Maybe omit it?



Comment at: clangd/index/Background.cpp:435
+for (const auto &P : LatestDigests)
+  LatestFileDigests[P.first] = P.second;
   }

I believe we want to avoid updating the digests for the dependencies if the 
digest for the main file has changed in the meantime.
Otherwise, we might record the stale versions of the dependency digests for the 
rest of the index lifetime.

Note that this might invalidate the assertion in `update() ` that checks all 
files have digests.



Comment at: clangd/index/Background.cpp:586
+  }
+  // FIXME: this should rebuild once-in-a-while, not after every file.
+  //   At that point we should use Dex, too.

Didn't we land the periodic rebuilds? Should this be obsolete now?



Comment at: clangd/index/Background.h:117
   llvm::StringMap IndexedFileDigests; // Key is absolute file path.
+  llvm::StringMap LatestFileDigests;  // Key is absolute file path.
   std::mutex DigestsMu;

NIT: maybe add a comment that we use this to decide which of the concurrently 
running indexing operations should take precedence?



Comment at: clangd/index/SymbolCollector.cpp:213
 bool isPreferredDeclaration(const NamedDecl &ND, index::SymbolRoleSet Roles) {
-  const auto& SM = ND.getASTContext().getSourceManager();
+  const auto &SM = ND.getASTContext().getSourceManager();
   return (Roles & static_cast(index::SymbolRole::Definition)) &&

NIT: look unrelated, maybe land as a separate NFC commit right away?
Not a big deal, though, feel free to ignore


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55224



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


[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

As discussed offline, let's remove the parts of the change that were aiming to 
fix the consistency issues, the issues were there before this patch, the fix is 
getting complicated and doesn't really solve all of the problems. All of that 
suggests it's out of scope for this change.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55224



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


[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 181044.
kadircet marked 10 inline comments as done.
kadircet added a comment.

Address comments & revert last changes


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55224

Files:
  clangd/index/Background.cpp
  clangd/index/Background.h
  test/clangd/background-index.test
  unittests/clangd/BackgroundIndexTests.cpp

Index: unittests/clangd/BackgroundIndexTests.cpp
===
--- unittests/clangd/BackgroundIndexTests.cpp
+++ unittests/clangd/BackgroundIndexTests.cpp
@@ -9,6 +9,7 @@
 
 using testing::_;
 using testing::AllOf;
+using testing::Contains;
 using testing::ElementsAre;
 using testing::Not;
 using testing::UnorderedElementsAre;
@@ -146,7 +147,7 @@
FileURI("unittest:///root/B.cc")}));
 }
 
-TEST_F(BackgroundIndexTest, ShardStorageWriteTest) {
+TEST_F(BackgroundIndexTest, ShardStorageTest) {
   MockFSProvider FS;
   FS.Files[testPath("root/A.h")] = R"cpp(
   void common();
@@ -175,6 +176,16 @@
   EXPECT_EQ(CacheHits, 0U);
   EXPECT_EQ(Storage.size(), 2U);
 
+  {
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return &MSS; });
+CDB.setCompileCommand(testPath("root"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+  EXPECT_EQ(CacheHits, 2U); // Check both A.cc and A.h loaded from cache.
+  EXPECT_EQ(Storage.size(), 2U);
+
   auto ShardHeader = MSS.loadShard(testPath("root/A.h"));
   EXPECT_NE(ShardHeader, nullptr);
   EXPECT_THAT(
@@ -278,5 +289,73 @@
   EXPECT_THAT(runFuzzyFind(Idx, ""), ElementsAre(Named("Y")));
 }
 
+TEST_F(BackgroundIndexTest, ShardStorageLoad) {
+  MockFSProvider FS;
+  FS.Files[testPath("root/A.h")] = R"cpp(
+  void common();
+  void f_b();
+  class A_CC {};
+  )cpp";
+  FS.Files[testPath("root/A.cc")] =
+  "#include \"A.h\"\nvoid g() { (void)common; }";
+
+  llvm::StringMap Storage;
+  size_t CacheHits = 0;
+  MemoryShardStorage MSS(Storage, CacheHits);
+
+  tooling::CompileCommand Cmd;
+  Cmd.Filename = testPath("root/A.cc");
+  Cmd.Directory = testPath("root");
+  Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
+  // Check nothing is loaded from Storage, but A.cc and A.h has been stored.
+  {
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return &MSS; });
+CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+
+  // Change header.
+  FS.Files[testPath("root/A.h")] = R"cpp(
+  void common();
+  void f_b();
+  class A_CC {};
+  class A_CCnew {};
+  )cpp";
+  {
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return &MSS; });
+CDB.setCompileCommand(testPath("root"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+  EXPECT_EQ(CacheHits, 2U); // Check both A.cc and A.h loaded from cache.
+
+  // Check if the new symbol has arrived.
+  auto ShardHeader = MSS.loadShard(testPath("root/A.h"));
+  EXPECT_NE(ShardHeader, nullptr);
+  EXPECT_THAT(*ShardHeader->Symbols, Contains(Named("A_CCnew")));
+
+  // Change source.
+  FS.Files[testPath("root/A.cc")] =
+  "#include \"A.h\"\nvoid g() { (void)common; }\nvoid f_b() {}";
+  {
+CacheHits = 0;
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return &MSS; });
+CDB.setCompileCommand(testPath("root"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+  EXPECT_EQ(CacheHits, 2U); // Check both A.cc and A.h loaded from cache.
+
+  // Check if the new symbol has arrived.
+  auto ShardSource = MSS.loadShard(testPath("root/A.cc"));
+  EXPECT_NE(ShardHeader, nullptr);
+  EXPECT_THAT(*ShardSource->Symbols,
+  Contains(AllOf(Named("f_b"), Declared(), Defined(;
+}
+
 } // namespace clangd
 } // namespace clang
Index: test/clangd/background-index.test
===
--- test/clangd/background-index.test
+++ test/clangd/background-index.test
@@ -16,6 +16,5 @@
 # RUN: ls %t/.clangd-index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
-# FIXME: This test currently fails as we don't read the index yet.
 # RUN: rm %t/foo.cpp
-# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | not FileCheck %t/definition.jsonrpc
+# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
Index: clangd/index/Background.h
===
--- clangd/index/Background.h
+++ clangd/index/Background.h
@@ -81,7 +81,6 @@
   // The indexing happens

[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check

2019-01-10 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber updated this revision to Diff 181051.
bernhardmgruber added a comment.

Fixed a warning when building with gcc. Added -fdeclspec when running tests to 
let them compile on Linux as well.


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

https://reviews.llvm.org/D56160

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseTrailingReturnCheck.cpp
  clang-tidy/modernize/UseTrailingReturnCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-trailing-return.rst
  test/clang-tidy/modernize-use-trailing-return.cpp

Index: test/clang-tidy/modernize-use-trailing-return.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-trailing-return.cpp
@@ -0,0 +1,269 @@
+// RUN: %check_clang_tidy %s modernize-use-trailing-return %t -- -- --std=c++14 -fdeclspec
+
+namespace std {
+template 
+class vector;
+
+class string;
+}
+
+//
+// Functions
+//
+
+int f();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f() -> int;{{$}}
+int f(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int) -> int;{{$}}
+int f(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int arg) -> int;{{$}}
+int f(int arg1, int arg2, int arg3);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int arg1, int arg2, int arg3) -> int;{{$}}
+int f(int arg1, int arg2, int arg3, ...);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int arg1, int arg2, int arg3, ...) -> int;{{$}}
+template  int f(T t);
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}template  auto f(T t) -> int;{{$}}
+
+//
+// Functions with formatting
+//
+
+int a1() { return 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a1() -> int { return 42; }{{$}}
+int a2() {
+return 42;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a2() -> int {{{$}}
+int a3()
+{
+return 42;
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a3() -> int{{$}}
+int a4(int   arg   )   ;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a4(int   arg   ) -> int   ;{{$}}
+int a5
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a5{{$}}
+(int arg);
+// CHECK-FIXES: {{^}}(int arg) -> int;{{$}}
+
+//
+// Functions with qualifiers and specifiers
+//
+
+inline int d1(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}inline auto d1(int arg) -> int;{{$}}
+extern "C" int d2(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}extern "C" auto d2(int arg) -> int;{{$}}
+inline int d3(int arg) noexcept(true);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}inline auto d3(int arg) -> int noexcept(true);{{$}}
+inline int d4(int arg) try { } catch(...) { }
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}inline auto d4(int arg) -> int try { } catch(...) { }{{$}}
+
+//
+// Functions in namespaces
+//
+
+namespace N {
+int e1();
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto e1() -> int;{{$}}
+int N::e1() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto N::e1() -> int {}{{$}}
+
+//
+// Functions with complex return types
+//
+
+inline volatile const std::vector e2();
+// CHECK-MESSAGES: :[[@LINE-1]]:48: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXE

[PATCH] D56225: [HIP] Use nul instead of /dev/null when running on windows

2019-01-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: lib/Driver/ToolChains/HIP.cpp:210
   std::string BundlerTargetArg = "-targets=host-x86_64-unknown-linux";
-  std::string BundlerInputArg = "-inputs=/dev/null";
+  std::string BundlerInputArg = "-inputs=" NULL_FILE;
 

rjmccall wrote:
> How hard would it be to just implement the TODO and get away from a reliance 
> on a null file?
I tried to make clang-offloader-bundler work without host target but it is not 
easy. Since it is shared with other languages e.g. OpenMP, it has a fundamental 
assumption that there is one host target. To make it work without host target 
may result in format changes that affecting HIP runtime, which is something I 
would like to avoid for now.


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

https://reviews.llvm.org/D56225



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


[PATCH] D55488: Add utility for dumping a label with child nodes

2019-01-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Aside from cosmetic nits, this LGTM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55488



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


[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56318#1346991 , @rjmccall wrote:

> Okay.  Is there a reasonable way to make your targets delegate to a different 
> `TargetInfo` implementation for most things so that you can generally match 
> the host target for things like type sizes and alignments?


There is TargetInfo for AuxTarget. In this case, the main target is amdgpu and 
the AuxTarget is x86_64. I am thinking maybe I can add a SizeTTarget pointer to 
ASTContext, and add a hook shouldDelegateSizeTTypeToAuxTarget to TargetInfo. If 
it is true, then ASTContext use size_t type in AuxTarget.


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

https://reviews.llvm.org/D56318



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


[PATCH] D53199: Fix the behavior of clang's -w flag.

2019-01-10 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Ping.


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

https://reviews.llvm.org/D53199



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


Re: r350776 - [Sema] Mark target of __attribute__((alias("target"))) used for C

2019-01-10 Thread Nico Weber via cfe-commits
Aren't C names sometimes slightly mangled too? For example, on macOS
they're prefixed by a _, doesn't that have to be undone there?

On Wed, Jan 9, 2019 at 6:58 PM Nick Desaulniers via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: nickdesaulniers
> Date: Wed Jan  9 15:54:55 2019
> New Revision: 350776
>
> URL: http://llvm.org/viewvc/llvm-project?rev=350776&view=rev
> Log:
> [Sema] Mark target of __attribute__((alias("target"))) used for C
>
> Summary:
> Prevents -Wunneeded-internal-delcaration warnings when the target has no
> other references. This occurs frequently in device drivers in the Linux
> kernel.
>
> Sema would need to invoke the demangler on the target, since in C++ the
> target name is mangled:
>
> int f() { return 42; }
> int g() __attribute__((alias("_Z1fv")));
>
> Sema does not have the ability to demangle names at this time.
>
> https://bugs.llvm.org/show_bug.cgi?id=39088
> https://github.com/ClangBuiltLinux/linux/issues/232
>
> Reviewers: rsmith, rjmccall
>
> Reviewed By: rsmith
>
> Subscribers: erik.pilkington, cfe-commits, pirama, srhines
>
> Differential Revision: https://reviews.llvm.org/D54188
>
> Added:
> cfe/trunk/test/Sema/alias-unused.c
> Modified:
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=350776&r1=350775&r2=350776&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Jan  9 15:54:55 2019
> @@ -1898,7 +1898,16 @@ static void handleAliasAttr(Sema &S, Dec
>  }
>}
>
> -  // FIXME: check if target symbol exists in current file
> +  // Mark target used to prevent unneeded-internal-declaration warnings.
> +  if (!S.LangOpts.CPlusPlus) {
> +// FIXME: demangle Str for C++, as the attribute refers to the mangled
> +// linkage name, not the pre-mangled identifier.
> +const DeclarationNameInfo target(&S.Context.Idents.get(Str),
> AL.getLoc());
> +LookupResult LR(S, target, Sema::LookupOrdinaryName);
> +if (S.LookupQualifiedName(LR, S.getCurLexicalContext()))
> +  for (NamedDecl *ND : LR)
> +ND->markUsed(S.Context);
> +  }
>
>D->addAttr(::new (S.Context) AliasAttr(AL.getRange(), S.Context, Str,
>
> AL.getAttributeSpellingListIndex()));
>
> Added: cfe/trunk/test/Sema/alias-unused.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/alias-unused.c?rev=350776&view=auto
>
> ==
> --- cfe/trunk/test/Sema/alias-unused.c (added)
> +++ cfe/trunk/test/Sema/alias-unused.c Wed Jan  9 15:54:55 2019
> @@ -0,0 +1,7 @@
> +// RUN: %clang_cc1 -triple x86_64-linux-gnu
> -Wunneeded-internal-declaration -x c -verify %s
> +// expected-no-diagnostics
> +static int f() { return 42; }
> +int g() __attribute__((alias("f")));
> +
> +static int foo [] = { 42, 0xDEAD };
> +extern typeof(foo) bar __attribute__((unused, alias("foo")));
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51641: [VFS] Cache the current working directory for the real FS.

2019-01-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D51641#1351283 , @labath wrote:

> I wholeheartedly support an openat(2) based VFS, as the current one falls 
> short of the expectations you have of it and is pretty broken right now.


Let me bait-and-switch then... D56545  adds a 
VFS that **emulates** `openat()` using path manipulation.

Since `openat` isn't available everywhere, to use it we'd need:

1. `openat`-like implementation of path ops
2. a fallback path-based implementation
3. new APIs to expose this from `llvm::sys::fs::`
4. a factory for the `openat`-like VFS

but I think it's less invasive and controversial to start with just 2 and 4.

> In fact, it still happens now, because the VFS is so bad at having a local 
> CWD. So, the only reason we actually discovered this was because  
> VFS->getCurrentWorkingDirectory returned an empty string if a it's CWD has 
> never been set. This later translated to a null pointer and a crash.

(Hmm, `RealFileSystem::getCurrentWorkingDirectory shouldn't return empty unless 
`fs::current_path()` does. But certainly here be dragons)

> So it almost sounds to me like we should have two implementations of the VFS. 
> A "real" one, which shared the CWD with the OS, and an "almost real" one, 
> which has a local CWD. Another position would be to just say that lldb was 
> wrong to use the VFS in the first place, as it does not promise we want (and 
> it should use a different abstraction instead). That view would be supported 
> by the fact that there are other interface disconnects relating to the use of 
> VFS in lldb (FILE* and friends). However, that's something you and Jonas will 
> have to figure out (I'm just the peanut gallery here :P).

Yeah - I will confess to finding LLDB's use of VFS difficult - doing some but 
not all operations through the VFS seems to constrains its implementation and 
makes the abstraction leakier.
But practically, I think you're right. And the default should probably stay 
as-is, at least until we have `openat()` on most platforms, or multithreading 
becomes more pervasive in LLVM-land.
D56545  rips out the cache for the default 
version, and explicitly guarantees synchronization with the OS workdir.


Repository:
  rC Clang

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

https://reviews.llvm.org/D51641



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


[PATCH] D55492: Implement Attr dumping in terms of visitors

2019-01-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/AST/TextNodeDumper.h:187
+
+// Implements Visit methods for Attrs
+#include "clang/AST/AttrTextNodeDump.inc"

Add a full stop to the end of the comment.



Comment at: lib/AST/ASTDumper.cpp:89
 // Utilities
-void dumpType(QualType T) { NodeDumper.dumpType(T); }
 void dumpTypeAsChild(QualType T);

This seems unrelated to this patch (same below) ?



Comment at: lib/AST/ASTDumper.cpp:443
+
+// Implements Visit methods for Attrs
+#include "clang/AST/AttrNodeTraverse.inc"

Full stop here as well.



Comment at: lib/AST/TextNodeDumper.cpp:44-45
 
+void TextNodeDumper::Visit(const Attr *A) {
+  {
+ColorScope Color(OS, ShowColors, AttrColor);

Formatting is incorrect.



Comment at: utils/TableGen/ClangAttrEmitter.cpp:3726
+functionContent = SS.str();
+if (SS.tell()) {
+  OS << "  void Visit" << R.getName() << "Attr(const " << R.getName()

steveire wrote:
> aaron.ballman wrote:
> > Wouldn't this be `!FunctionContent.empty()`?
> I would have thought so, but apparently that's not how `raw_string_ostream` 
> works. I get an empty file from this if I do that.
Huh, good to know.



Comment at: utils/TableGen/ClangAttrEmitter.cpp:3738
+void EmitClangAttrNodeTraverse(RecordKeeper &Records, raw_ostream &OS) {
+  emitSourceFileHeader("Attribute text node dumper", OS);
+

The source file comment will be incorrect. This emits the node traverser not 
the dumper.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55492



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


[PATCH] D50766: Fix false positive unsequenced access and modification warning in array subscript expression.

2019-01-10 Thread Mateusz Janek via Phabricator via cfe-commits
stryku added a comment.

Hi again, since I don't have commit rights, could you please merge this patch 
into the project sources? Thanks in advance.


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

https://reviews.llvm.org/D50766



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


[PATCH] D51641: [VFS] Cache the current working directory for the real FS.

2019-01-10 Thread Pavel Labath via Phabricator via cfe-commits
labath added a comment.

In D51641#1352782 , @sammccall wrote:

> > In fact, it still happens now, because the VFS is so bad at having a local 
> > CWD. So, the only reason we actually discovered this was because  
> > VFS->getCurrentWorkingDirectory returned an empty string if a it's CWD has 
> > never been set. This later translated to a null pointer and a crash.
>
> (Hmm, `RealFileSystem::getCurrentWorkingDirectory shouldn't return empty 
> unless `fs::current_path()` does. But certainly here be dragons)


My bad. After re-reading the original report it seems that happened was that we 
got a stale CWD, then went to search for a file that we expected to be there 
(but it wasn't, because we were searching in the wrong place), and *then* we 
crashed. :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D51641



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


[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Only one important comment about bringing back the comment.




Comment at: clangd/index/Background.cpp:224
+auto NeedsReIndexing = loadShards(std::move(ChangedFiles));
+// Run indexing for files that needs to be updated.
+std::shuffle(NeedsReIndexing.begin(), NeedsReIndexing.end(),

a typo: s/that needs/that need/



Comment at: clangd/index/Background.cpp:344
+  DigestIt.first->second = Hash;
+  IndexedSymbols.update(Path, std::move(SS), std::move(RS));
+}

Let's bring back the comment about rewriting the newer version.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55224



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


[PATCH] D55491: Implement TemplateArgument dumping in terms of Visitor

2019-01-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/AST/TemplateArgumentVisitor.h:23
+
+template  struct make_ref { using type = T &; };
+template  struct make_const_ref { using type = const T &; };

`std::add_lvalue_reference<>` already does this, so do we really need this?



Comment at: include/clang/AST/TemplateArgumentVisitor.h:24
+template  struct make_ref { using type = T &; };
+template  struct make_const_ref { using type = const T &; };
+

I'm guessing we can't use `std::add_lvalue_reference>` for the 
same reasons we couldn't use it for pointers, but then `make_const_ref` should 
live in STLExtras.h and not here (it's generally useful).



Comment at: include/clang/AST/TemplateArgumentVisitor.h:27-28
+/// A simple visitor class that helps create template argument visitors.
+template  class Ref, typename ImplClass,
+  typename RetTy = void, class... ParamTys>
+class Base {

s/class/typename to be self-consistent



Comment at: include/clang/AST/TemplateArgumentVisitor.h:55
+
+  RetTy VisitNullTemplateArgument(REF(TemplateArgument) TA, ParamTys... P) {
+return VisitTemplateArgument(TA, std::forward(P)...);

Might be worth it to replace these with a macro, sort of like how `DISPATCH` is 
used above.



Comment at: include/clang/AST/TextNodeDumper.h:156
+  void Visit(const TemplateArgument &TA, SourceRange R,
+ const Decl *From = nullptr, const char *label = nullptr);
+

label -> Label and I think we should use a `StringRef` for the type.



Comment at: lib/AST/ASTDumper.cpp:449-450
+void VisitPackTemplateArgument(const TemplateArgument &TA) {
+  for (TemplateArgument::pack_iterator I = TA.pack_begin(),
+   E = TA.pack_end();
+   I != E; ++I)

`llvm::for_each(TA.pack_elements(), ...);` (or a range-based for loop)



Comment at: lib/AST/TextNodeDumper.cpp:68
+void TextNodeDumper::Visit(const TemplateArgument &TA, SourceRange R,
+   const Decl *From, const char *label) {
+  OS << "TemplateArgument";

label -> Label



Comment at: lib/AST/TextNodeDumper.cpp:73
+
+  if (From) {
+dumpDeclRef(From, label);

Elide braces


Repository:
  rC Clang

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

https://reviews.llvm.org/D55491



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


[PATCH] D56405: Split -Wdelete-non-virtual-dtor into two groups

2019-01-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


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

https://reviews.llvm.org/D56405



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


[PATCH] D53928: Enable builtins necessary for SLEEF [AArch64] vectorized trigonometry libm functions

2019-01-10 Thread Stefan Teleman via Phabricator via cfe-commits
steleman added a comment.

Ping!

Yes, I know, everyone was away for the holidays. :-)

Could someone please take a look at this. We'd like to make sure everything is 
OK on this side before D53927  can proceed.

Yes, it's a bit of a circular dependency in that sense.

This changeset doesn't cover any of the problems with OpenMP and conflicting 
pragmas and semantics described above by Renato. This is just the clang side of 
straightforward mapping of SLEEF vectorized function calls.


Repository:
  rC Clang

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

https://reviews.llvm.org/D53928



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


[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 181072.
kadircet marked 2 inline comments as done.
kadircet added a comment.

Address comments


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55224

Files:
  clangd/index/Background.cpp
  clangd/index/Background.h
  test/clangd/background-index.test
  unittests/clangd/BackgroundIndexTests.cpp

Index: unittests/clangd/BackgroundIndexTests.cpp
===
--- unittests/clangd/BackgroundIndexTests.cpp
+++ unittests/clangd/BackgroundIndexTests.cpp
@@ -9,6 +9,7 @@
 
 using testing::_;
 using testing::AllOf;
+using testing::Contains;
 using testing::ElementsAre;
 using testing::Not;
 using testing::UnorderedElementsAre;
@@ -146,7 +147,7 @@
FileURI("unittest:///root/B.cc")}));
 }
 
-TEST_F(BackgroundIndexTest, ShardStorageWriteTest) {
+TEST_F(BackgroundIndexTest, ShardStorageTest) {
   MockFSProvider FS;
   FS.Files[testPath("root/A.h")] = R"cpp(
   void common();
@@ -175,6 +176,16 @@
   EXPECT_EQ(CacheHits, 0U);
   EXPECT_EQ(Storage.size(), 2U);
 
+  {
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return &MSS; });
+CDB.setCompileCommand(testPath("root"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+  EXPECT_EQ(CacheHits, 2U); // Check both A.cc and A.h loaded from cache.
+  EXPECT_EQ(Storage.size(), 2U);
+
   auto ShardHeader = MSS.loadShard(testPath("root/A.h"));
   EXPECT_NE(ShardHeader, nullptr);
   EXPECT_THAT(
@@ -278,5 +289,73 @@
   EXPECT_THAT(runFuzzyFind(Idx, ""), ElementsAre(Named("Y")));
 }
 
+TEST_F(BackgroundIndexTest, ShardStorageLoad) {
+  MockFSProvider FS;
+  FS.Files[testPath("root/A.h")] = R"cpp(
+  void common();
+  void f_b();
+  class A_CC {};
+  )cpp";
+  FS.Files[testPath("root/A.cc")] =
+  "#include \"A.h\"\nvoid g() { (void)common; }";
+
+  llvm::StringMap Storage;
+  size_t CacheHits = 0;
+  MemoryShardStorage MSS(Storage, CacheHits);
+
+  tooling::CompileCommand Cmd;
+  Cmd.Filename = testPath("root/A.cc");
+  Cmd.Directory = testPath("root");
+  Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
+  // Check nothing is loaded from Storage, but A.cc and A.h has been stored.
+  {
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return &MSS; });
+CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+
+  // Change header.
+  FS.Files[testPath("root/A.h")] = R"cpp(
+  void common();
+  void f_b();
+  class A_CC {};
+  class A_CCnew {};
+  )cpp";
+  {
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return &MSS; });
+CDB.setCompileCommand(testPath("root"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+  EXPECT_EQ(CacheHits, 2U); // Check both A.cc and A.h loaded from cache.
+
+  // Check if the new symbol has arrived.
+  auto ShardHeader = MSS.loadShard(testPath("root/A.h"));
+  EXPECT_NE(ShardHeader, nullptr);
+  EXPECT_THAT(*ShardHeader->Symbols, Contains(Named("A_CCnew")));
+
+  // Change source.
+  FS.Files[testPath("root/A.cc")] =
+  "#include \"A.h\"\nvoid g() { (void)common; }\nvoid f_b() {}";
+  {
+CacheHits = 0;
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return &MSS; });
+CDB.setCompileCommand(testPath("root"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+  EXPECT_EQ(CacheHits, 2U); // Check both A.cc and A.h loaded from cache.
+
+  // Check if the new symbol has arrived.
+  auto ShardSource = MSS.loadShard(testPath("root/A.cc"));
+  EXPECT_NE(ShardHeader, nullptr);
+  EXPECT_THAT(*ShardSource->Symbols,
+  Contains(AllOf(Named("f_b"), Declared(), Defined(;
+}
+
 } // namespace clangd
 } // namespace clang
Index: test/clangd/background-index.test
===
--- test/clangd/background-index.test
+++ test/clangd/background-index.test
@@ -16,6 +16,5 @@
 # RUN: ls %t/.clangd-index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
-# FIXME: This test currently fails as we don't read the index yet.
 # RUN: rm %t/foo.cpp
-# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | not FileCheck %t/definition.jsonrpc
+# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
Index: clangd/index/Background.h
===
--- clangd/index/Background.h
+++ clangd/index/Background.h
@@ -81,7 +81,6 @@
   // The indexing happens in a background thread

[PATCH] D56441: [analyzer][CrossTU][NFC] Generalize to external definitions instead of external functions

2019-01-10 Thread Rafael Stahl via Phabricator via cfe-commits
r.stahl updated this revision to Diff 181073.
r.stahl added a comment.

addressed review comments


Repository:
  rC Clang

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

https://reviews.llvm.org/D56441

Files:
  include/clang/Basic/DiagnosticCrossTUKinds.td
  include/clang/CrossTU/CrossTranslationUnit.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  lib/CrossTU/CrossTranslationUnit.cpp
  test/Analysis/Inputs/ctu-other.c.externalDefMap.txt
  test/Analysis/Inputs/ctu-other.c.externalFnMap.txt
  test/Analysis/Inputs/ctu-other.cpp.externalDefMap.txt
  test/Analysis/Inputs/ctu-other.cpp.externalFnMap.txt
  test/Analysis/analyzer-config.c
  test/Analysis/ctu-different-triples.cpp
  test/Analysis/ctu-main.c
  test/Analysis/ctu-main.cpp
  test/Analysis/ctu-unknown-parts-in-triples.cpp
  test/Analysis/func-mapping-test.cpp
  test/CMakeLists.txt
  test/lit.cfg.py
  tools/CMakeLists.txt
  tools/clang-extdef-mapping/
  tools/clang-extdef-mapping/CMakeLists.txt
  tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
  tools/clang-func-mapping/CMakeLists.txt
  tools/clang-func-mapping/ClangFnMapGen.cpp
  tools/scan-build-py/README.md
  tools/scan-build-py/libscanbuild/__init__.py
  tools/scan-build-py/libscanbuild/analyze.py
  tools/scan-build-py/libscanbuild/arguments.py
  tools/scan-build-py/libscanbuild/clang.py
  tools/scan-build-py/tests/unit/test_analyze.py
  tools/scan-build-py/tests/unit/test_clang.py

Index: tools/scan-build-py/tests/unit/test_clang.py
===
--- tools/scan-build-py/tests/unit/test_clang.py
+++ tools/scan-build-py/tests/unit/test_clang.py
@@ -96,7 +96,7 @@
 
 class ClangIsCtuCapableTest(unittest.TestCase):
 def test_ctu_not_found(self):
-is_ctu = sut.is_ctu_capable('not-found-clang-func-mapping')
+is_ctu = sut.is_ctu_capable('not-found-clang-extdef-mapping')
 self.assertFalse(is_ctu)
 
 
Index: tools/scan-build-py/tests/unit/test_analyze.py
===
--- tools/scan-build-py/tests/unit/test_analyze.py
+++ tools/scan-build-py/tests/unit/test_analyze.py
@@ -349,14 +349,14 @@
 class MergeCtuMapTest(unittest.TestCase):
 
 def test_no_map_gives_empty(self):
-pairs = sut.create_global_ctu_function_map([])
+pairs = sut.create_global_ctu_extdef_map([])
 self.assertFalse(pairs)
 
 def test_multiple_maps_merged(self):
 concat_map = ['c:@F@fun1#I# ast/fun1.c.ast',
   'c:@F@fun2#I# ast/fun2.c.ast',
   'c:@F@fun3#I# ast/fun3.c.ast']
-pairs = sut.create_global_ctu_function_map(concat_map)
+pairs = sut.create_global_ctu_extdef_map(concat_map)
 self.assertTrue(('c:@F@fun1#I#', 'ast/fun1.c.ast') in pairs)
 self.assertTrue(('c:@F@fun2#I#', 'ast/fun2.c.ast') in pairs)
 self.assertTrue(('c:@F@fun3#I#', 'ast/fun3.c.ast') in pairs)
@@ -366,7 +366,7 @@
 concat_map = ['c:@F@fun1#I# ast/fun1.c.ast',
   'c:@F@fun2#I# ast/fun2.c.ast',
   'c:@F@fun1#I# ast/fun7.c.ast']
-pairs = sut.create_global_ctu_function_map(concat_map)
+pairs = sut.create_global_ctu_extdef_map(concat_map)
 self.assertFalse(('c:@F@fun1#I#', 'ast/fun1.c.ast') in pairs)
 self.assertFalse(('c:@F@fun1#I#', 'ast/fun7.c.ast') in pairs)
 self.assertTrue(('c:@F@fun2#I#', 'ast/fun2.c.ast') in pairs)
@@ -376,28 +376,28 @@
 concat_map = ['c:@F@fun1#I# ast/fun1.c.ast',
   'c:@F@fun2#I# ast/fun2.c.ast',
   'c:@F@fun1#I# ast/fun1.c.ast']
-pairs = sut.create_global_ctu_function_map(concat_map)
+pairs = sut.create_global_ctu_extdef_map(concat_map)
 self.assertTrue(('c:@F@fun1#I#', 'ast/fun1.c.ast') in pairs)
 self.assertTrue(('c:@F@fun2#I#', 'ast/fun2.c.ast') in pairs)
 self.assertEqual(2, len(pairs))
 
 def test_space_handled_in_source(self):
 concat_map = ['c:@F@fun1#I# ast/f un.c.ast']
-pairs = sut.create_global_ctu_function_map(concat_map)
+pairs = sut.create_global_ctu_extdef_map(concat_map)
 self.assertTrue(('c:@F@fun1#I#', 'ast/f un.c.ast') in pairs)
 self.assertEqual(1, len(pairs))
 
 
-class FuncMapSrcToAstTest(unittest.TestCase):
+class ExtdefMapSrcToAstTest(unittest.TestCase):
 
 def test_empty_gives_empty(self):
-fun_ast_lst = sut.func_map_list_src_to_ast([])
+fun_ast_lst = sut.extdef_map_list_src_to_ast([])
 self.assertFalse(fun_ast_lst)
 
 def test_sources_to_asts(self):
 fun_src_lst = ['c:@F@f1#I# ' + os.path.join(os.sep + 'path', 'f1.c'),
'c:@F@f2#I# ' + os.path.join(os.sep + 'path', 'f2.c')]
-fun_ast_lst = sut.func_map_list_src_to_ast(fun_src_lst)
+fun_ast_lst = sut.extdef_map_list_src_to_ast(fun_src_lst)
 self.assertTrue('c:@F@f1#I# ' +

[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-10 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

@joerg if you think that this patch is OK, please click accept so we can be 
aware that this is what you want.


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

https://reviews.llvm.org/D56215



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


[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM. Ship it!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55224



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


[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE350847: [clangd] Introduce loading of shards within 
auto-index (authored by kadircet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55224?vs=181072&id=181075#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55224

Files:
  clangd/index/Background.cpp
  clangd/index/Background.h
  test/clangd/background-index.test
  unittests/clangd/BackgroundIndexTests.cpp

Index: clangd/index/Background.h
===
--- clangd/index/Background.h
+++ clangd/index/Background.h
@@ -81,7 +81,6 @@
   // The indexing happens in a background thread, so the symbols will be
   // available sometime later.
   void enqueue(const std::vector &ChangedFiles);
-  void enqueue(const std::string &File);
 
   // Cause background threads to stop after ther current task, any remaining
   // tasks will be discarded.
@@ -118,6 +117,21 @@
   std::mutex DigestsMu;
 
   BackgroundIndexStorage::Factory IndexStorageFactory;
+  struct Source {
+std::string Path;
+bool NeedsReIndexing;
+Source(llvm::StringRef Path, bool NeedsReIndexing)
+: Path(Path), NeedsReIndexing(NeedsReIndexing) {}
+  };
+  // Loads the shards for a single TU and all of its dependencies. Returns the
+  // list of sources and whether they need to be re-indexed.
+  std::vector loadShard(const tooling::CompileCommand &Cmd,
+BackgroundIndexStorage *IndexStorage,
+llvm::StringSet<> &LoadedShards);
+  // Tries to load shards for the ChangedFiles.
+  std::vector>
+  loadShards(std::vector ChangedFiles);
+  void enqueue(tooling::CompileCommand Cmd, BackgroundIndexStorage *Storage);
 
   // queue management
   using Task = std::function;
Index: clangd/index/Background.cpp
===
--- clangd/index/Background.cpp
+++ clangd/index/Background.cpp
@@ -115,6 +115,19 @@
   };
 }
 
+// We cannot use vfs->makeAbsolute because Cmd.FileName is either absolute or
+// relative to Cmd.Directory, which might not be the same as current working
+// directory.
+llvm::SmallString<128> getAbsolutePath(const tooling::CompileCommand &Cmd) {
+  llvm::SmallString<128> AbsolutePath;
+  if (llvm::sys::path::is_absolute(Cmd.Filename)) {
+AbsolutePath = Cmd.Filename;
+  } else {
+AbsolutePath = Cmd.Directory;
+llvm::sys::path::append(AbsolutePath, Cmd.Filename);
+  }
+  return AbsolutePath;
+}
 } // namespace
 
 BackgroundIndex::BackgroundIndex(
@@ -204,40 +217,33 @@
   [this, ChangedFiles] {
 trace::Span Tracer("BackgroundIndexEnqueue");
 // We're doing this asynchronously, because we'll read shards here too.
-// FIXME: read shards here too.
-
 log("Enqueueing {0} commands for indexing", ChangedFiles.size());
 SPAN_ATTACH(Tracer, "files", int64_t(ChangedFiles.size()));
 
-// We shuffle the files because processing them in a random order should
-// quickly give us good coverage of headers in the project.
-std::vector Permutation(ChangedFiles.size());
-std::iota(Permutation.begin(), Permutation.end(), 0);
-std::mt19937 Generator(std::random_device{}());
-std::shuffle(Permutation.begin(), Permutation.end(), Generator);
-
-for (const unsigned I : Permutation)
-  enqueue(ChangedFiles[I]);
+auto NeedsReIndexing = loadShards(std::move(ChangedFiles));
+// Run indexing for files that need to be updated.
+std::shuffle(NeedsReIndexing.begin(), NeedsReIndexing.end(),
+ std::mt19937(std::random_device{}()));
+for (auto &Elem : NeedsReIndexing)
+  enqueue(std::move(Elem.first), Elem.second);
   },
   ThreadPriority::Normal);
 }
 
-void BackgroundIndex::enqueue(const std::string &File) {
-  ProjectInfo Project;
-  if (auto Cmd = CDB.getCompileCommand(File, &Project)) {
-auto *Storage = IndexStorageFactory(Project.SourceRoot);
-// Set priority to low, since background indexing is a long running
-// task we do not want to eat up cpu when there are any other high
-// priority threads.
-enqueueTask(Bind(
-[this, File, Storage](tooling::CompileCommand Cmd) {
-  Cmd.CommandLine.push_back("-resource-dir=" + ResourceDir);
-  if (auto Error = index(std::move(Cmd), Storage))
-log("Indexing {0} failed: {1}", File, std::move(Error));
-},
-std::move(*Cmd)),
-ThreadPriority::Low);
-  }
+void BackgroundIndex::enqueue(tooling::CompileCommand Cmd,
+  BackgroundIndexStorage *Storage) {
+  enqueueTask(Bind(
+  [this, Storage](tooling::CompileCommand Cmd) {
+  

[clang-tools-extra] r350847 - [clangd] Introduce loading of shards within auto-index

2019-01-10 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Thu Jan 10 09:03:04 2019
New Revision: 350847

URL: http://llvm.org/viewvc/llvm-project?rev=350847&view=rev
Log:
[clangd] Introduce loading of shards within auto-index

Summary:
Whenever a change happens on a CDB, load shards associated with that
CDB before issuing re-index actions.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/index/Background.cpp
clang-tools-extra/trunk/clangd/index/Background.h
clang-tools-extra/trunk/test/clangd/background-index.test
clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/Background.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.cpp?rev=350847&r1=350846&r2=350847&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Background.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Background.cpp Thu Jan 10 09:03:04 2019
@@ -115,6 +115,19 @@ createFileFilter(const llvm::StringMapmakeAbsolute because Cmd.FileName is either absolute or
+// relative to Cmd.Directory, which might not be the same as current working
+// directory.
+llvm::SmallString<128> getAbsolutePath(const tooling::CompileCommand &Cmd) {
+  llvm::SmallString<128> AbsolutePath;
+  if (llvm::sys::path::is_absolute(Cmd.Filename)) {
+AbsolutePath = Cmd.Filename;
+  } else {
+AbsolutePath = Cmd.Directory;
+llvm::sys::path::append(AbsolutePath, Cmd.Filename);
+  }
+  return AbsolutePath;
+}
 } // namespace
 
 BackgroundIndex::BackgroundIndex(
@@ -204,40 +217,33 @@ void BackgroundIndex::enqueue(const std:
   [this, ChangedFiles] {
 trace::Span Tracer("BackgroundIndexEnqueue");
 // We're doing this asynchronously, because we'll read shards here too.
-// FIXME: read shards here too.
-
 log("Enqueueing {0} commands for indexing", ChangedFiles.size());
 SPAN_ATTACH(Tracer, "files", int64_t(ChangedFiles.size()));
 
-// We shuffle the files because processing them in a random order 
should
-// quickly give us good coverage of headers in the project.
-std::vector Permutation(ChangedFiles.size());
-std::iota(Permutation.begin(), Permutation.end(), 0);
-std::mt19937 Generator(std::random_device{}());
-std::shuffle(Permutation.begin(), Permutation.end(), Generator);
-
-for (const unsigned I : Permutation)
-  enqueue(ChangedFiles[I]);
+auto NeedsReIndexing = loadShards(std::move(ChangedFiles));
+// Run indexing for files that need to be updated.
+std::shuffle(NeedsReIndexing.begin(), NeedsReIndexing.end(),
+ std::mt19937(std::random_device{}()));
+for (auto &Elem : NeedsReIndexing)
+  enqueue(std::move(Elem.first), Elem.second);
   },
   ThreadPriority::Normal);
 }
 
-void BackgroundIndex::enqueue(const std::string &File) {
-  ProjectInfo Project;
-  if (auto Cmd = CDB.getCompileCommand(File, &Project)) {
-auto *Storage = IndexStorageFactory(Project.SourceRoot);
-// Set priority to low, since background indexing is a long running
-// task we do not want to eat up cpu when there are any other high
-// priority threads.
-enqueueTask(Bind(
-[this, File, Storage](tooling::CompileCommand Cmd) {
-  Cmd.CommandLine.push_back("-resource-dir=" + 
ResourceDir);
-  if (auto Error = index(std::move(Cmd), Storage))
-log("Indexing {0} failed: {1}", File, 
std::move(Error));
-},
-std::move(*Cmd)),
-ThreadPriority::Low);
-  }
+void BackgroundIndex::enqueue(tooling::CompileCommand Cmd,
+  BackgroundIndexStorage *Storage) {
+  enqueueTask(Bind(
+  [this, Storage](tooling::CompileCommand Cmd) {
+Cmd.CommandLine.push_back("-resource-dir=" + ResourceDir);
+// We can't use llvm::StringRef here since we are going to
+// move from Cmd during the call below.
+const std::string FileName = Cmd.Filename;
+if (auto Error = index(std::move(Cmd), Storage))
+  elog("Indexing {0} failed: {1}", FileName,
+   std::move(Error));
+  },
+  std::move(Cmd)),
+  ThreadPriority::Low);
 }
 
 void BackgroundIndex::enqueueTask(Task T, ThreadPriority Priority) {
@@ -299,22 +305,22 @@ void BackgroundIndex::update(llvm::Strin
   }
 
   // Build and store new slabs for each updated file.
-  for (const auto &F : Files) {
-llvm::StringRef Path = F.first();
-vlog("Update symbols in {0}", Path);
+  for (const auto &I 

[PATCH] D55491: Implement TemplateArgument dumping in terms of Visitor

2019-01-10 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked an inline comment as done.
steveire added inline comments.



Comment at: lib/AST/ASTDumper.cpp:449-450
+void VisitPackTemplateArgument(const TemplateArgument &TA) {
+  for (TemplateArgument::pack_iterator I = TA.pack_begin(),
+   E = TA.pack_end();
+   I != E; ++I)

aaron.ballman wrote:
> `llvm::for_each(TA.pack_elements(), ...);` (or a range-based for loop)
I'm just moving the code as it is in its origin location. You could rewrite it 
separately if you wish.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55491



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


[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

If I was only concerned about `size_t`, your current solution would be fine.  
My concern is that you really need to match *all* of the associated CPU 
target's ABI choices, so your target really ought to be forwarding everything 
to that target by default and only selectively overriding it in order to 
support GPU-specific features.   Probably the easiest way to do that is via 
inheritance.


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

https://reviews.llvm.org/D56318



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


[PATCH] D56523: Improve a -Wunguarded-availability note

2019-01-10 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington marked an inline comment as done.
erik.pilkington added inline comments.



Comment at: clang/test/Sema/availability-guard-format.mm:6
 @interface foo
-- (void) method_bar __attribute__((availability(macosx, introduced = 10_12))); 
// expected-note {{'method_bar' has been explicitly marked partial here}}
+- (void) method_bar __attribute__((availability(macosx, introduced = 10_12))); 
// expected-note {{'method_bar' has been marked as being introduced in macOS 
10.12 here, but the deployment target is macOS 10.4.0}}
 @end

jkorous wrote:
> I am probably missing something but where is the deployment target value set?
Its set implicitly, but you can also control it with `-mmacos-version-min=` 
flag.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56523



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


[PATCH] D56532: [clang-tidy] Add the abseil-duration-conversion-cast check

2019-01-10 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

nit's come from running running validate_check.py on the rst file from D55523: 
[clang-tidy] Linting .rst documentation 

$ ../clang-tidy/validate_check.py --rst abseil-duration-conversion-cast.rst
Checking abseil-duration-conversion-cast.rst...
warning: line 6 maximize 80 characters by joining:'[Checks for casts of 
``absl::Duration`` conversion functions, and recommends]' and '[the...]

warning: line 20 multiple blank lines
warning: line 28 multiple blank lines




Comment at: docs/clang-tidy/checks/abseil-duration-conversion-cast.rst:20
+
+
+  // Original - Cast from a double to an integer

nit: double blank line



Comment at: docs/clang-tidy/checks/abseil-duration-conversion-cast.rst:28
+
+
+Note: In the second example, the suggested fix could yield a different result,

nit: double blank line



Comment at: docs/clang-tidy/checks/abseil-duration-conversion-cast.rst:31
+as the conversion to integer could truncate.  In practice, this is very rare,
+and you should use ``absl::Trunc`` to perform this operation explicitly
+instead.

nit: I believe that 'instead.' can come onto this line and still be <= 80 
characters (which might actually be a bug in validate_check.py that it doesn't 
detect it)


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56532



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


r350852 - [analyzer][CrossTU][NFC] Generalize to external definitions instead of external functions

2019-01-10 Thread Rafael Stahl via cfe-commits
Author: r.stahl
Date: Thu Jan 10 09:44:04 2019
New Revision: 350852

URL: http://llvm.org/viewvc/llvm-project?rev=350852&view=rev
Log:
[analyzer][CrossTU][NFC] Generalize to external definitions instead of external 
functions

Summary: This is just changing naming and documentation to be general about 
external definitions that can be imported for cross translation unit analysis. 
There is at least a plan to add VarDecls: D46421

Reviewers: NoQ, xazax.hun, martong, a.sidorin, george.karpenkov, 
serge-sans-paille

Reviewed By: xazax.hun, martong

Subscribers: mgorny, whisperity, baloghadamsoftware, szepet, rnkovacs, 
mikhail.ramalho, Szelethus, donat.nagy, dkrupp, cfe-commits

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

Added:
cfe/trunk/test/Analysis/Inputs/ctu-other.c.externalDefMap.txt   (props 
changed)
  - copied unchanged from r350851, 
cfe/trunk/test/Analysis/Inputs/ctu-other.c.externalFnMap.txt
cfe/trunk/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.txt   (props 
changed)
  - copied unchanged from r350851, 
cfe/trunk/test/Analysis/Inputs/ctu-other.cpp.externalFnMap.txt
cfe/trunk/tools/clang-extdef-mapping/
cfe/trunk/tools/clang-extdef-mapping/CMakeLists.txt   (contents, props 
changed)
  - copied, changed from r350851, 
cfe/trunk/tools/clang-func-mapping/CMakeLists.txt
cfe/trunk/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp   (contents, 
props changed)
  - copied, changed from r350851, 
cfe/trunk/tools/clang-func-mapping/ClangFnMapGen.cpp
Removed:
cfe/trunk/test/Analysis/Inputs/ctu-other.c.externalFnMap.txt
cfe/trunk/test/Analysis/Inputs/ctu-other.cpp.externalFnMap.txt
cfe/trunk/tools/clang-func-mapping/CMakeLists.txt
cfe/trunk/tools/clang-func-mapping/ClangFnMapGen.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCrossTUKinds.td
cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/test/Analysis/ctu-different-triples.cpp
cfe/trunk/test/Analysis/ctu-main.c
cfe/trunk/test/Analysis/ctu-main.cpp
cfe/trunk/test/Analysis/ctu-unknown-parts-in-triples.cpp
cfe/trunk/test/Analysis/func-mapping-test.cpp
cfe/trunk/test/CMakeLists.txt
cfe/trunk/test/lit.cfg.py
cfe/trunk/tools/CMakeLists.txt
cfe/trunk/tools/scan-build-py/README.md
cfe/trunk/tools/scan-build-py/libscanbuild/__init__.py
cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
cfe/trunk/tools/scan-build-py/libscanbuild/arguments.py
cfe/trunk/tools/scan-build-py/libscanbuild/clang.py
cfe/trunk/tools/scan-build-py/tests/unit/test_analyze.py
cfe/trunk/tools/scan-build-py/tests/unit/test_clang.py

Modified: cfe/trunk/include/clang/Basic/DiagnosticCrossTUKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCrossTUKinds.td?rev=350852&r1=350851&r2=350852&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCrossTUKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCrossTUKinds.td Thu Jan 10 09:44:04 
2019
@@ -12,7 +12,7 @@ let Component = "CrossTU" in {
 def err_ctu_error_opening : Error<
   "error opening '%0': required by the CrossTU functionality">;
 
-def err_fnmap_parsing : Error<
+def err_extdefmap_parsing : Error<
   "error parsing index file: '%0' line: %1 'UniqueID filename' format "
   "expected">;
 

Modified: cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h?rev=350852&r1=350851&r2=350852&view=diff
==
--- cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h (original)
+++ cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h Thu Jan 10 09:44:04 
2019
@@ -90,11 +90,11 @@ std::string createCrossTUIndexString(con
 /// This class is used for tools that requires cross translation
 ///unit capability.
 ///
-/// This class can load function definitions from external AST files.
+/// This class can load definitions from external AST files.
 /// The loaded definition will be merged back to the original AST using the
 /// AST Importer.
 /// In order to use this class, an index file is required that describes
-/// the locations of the AST files for each function definition.
+/// the locations of the AST files for each definition.
 ///
 /// Note that this class also implements caching.
 class CrossTranslationUnitContext {

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=350852&r1=350851&r2=350852&view=diff
==
--- cfe/trunk/in

[PATCH] D56441: [analyzer][CrossTU][NFC] Generalize to external definitions instead of external functions

2019-01-10 Thread Rafael Stahl via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350852: [analyzer][CrossTU][NFC] Generalize to external 
definitions instead of external… (authored by r.stahl, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56441?vs=181073&id=181079#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56441

Files:
  cfe/trunk/include/clang/Basic/DiagnosticCrossTUKinds.td
  cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
  cfe/trunk/test/Analysis/Inputs/ctu-other.c.externalDefMap.txt
  cfe/trunk/test/Analysis/Inputs/ctu-other.c.externalFnMap.txt
  cfe/trunk/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.txt
  cfe/trunk/test/Analysis/Inputs/ctu-other.cpp.externalFnMap.txt
  cfe/trunk/test/Analysis/analyzer-config.c
  cfe/trunk/test/Analysis/ctu-different-triples.cpp
  cfe/trunk/test/Analysis/ctu-main.c
  cfe/trunk/test/Analysis/ctu-main.cpp
  cfe/trunk/test/Analysis/ctu-unknown-parts-in-triples.cpp
  cfe/trunk/test/Analysis/func-mapping-test.cpp
  cfe/trunk/test/CMakeLists.txt
  cfe/trunk/test/lit.cfg.py
  cfe/trunk/tools/CMakeLists.txt
  cfe/trunk/tools/clang-extdef-mapping/CMakeLists.txt
  cfe/trunk/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
  cfe/trunk/tools/clang-func-mapping/CMakeLists.txt
  cfe/trunk/tools/clang-func-mapping/ClangFnMapGen.cpp
  cfe/trunk/tools/scan-build-py/README.md
  cfe/trunk/tools/scan-build-py/libscanbuild/__init__.py
  cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
  cfe/trunk/tools/scan-build-py/libscanbuild/arguments.py
  cfe/trunk/tools/scan-build-py/libscanbuild/clang.py
  cfe/trunk/tools/scan-build-py/tests/unit/test_analyze.py
  cfe/trunk/tools/scan-build-py/tests/unit/test_clang.py

Index: cfe/trunk/test/Analysis/ctu-different-triples.cpp
===
--- cfe/trunk/test/Analysis/ctu-different-triples.cpp
+++ cfe/trunk/test/Analysis/ctu-different-triples.cpp
@@ -2,7 +2,7 @@
 // RUN: mkdir -p %t/ctudir
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu \
 // RUN:   -emit-pch -o %t/ctudir/ctu-other.cpp.ast %S/Inputs/ctu-other.cpp
-// RUN: cp %S/Inputs/ctu-other.cpp.externalFnMap.txt %t/ctudir/externalFnMap.txt
+// RUN: cp %S/Inputs/ctu-other.cpp.externalDefMap.txt %t/ctudir/externalDefMap.txt
 // RUN: %clang_analyze_cc1 -triple powerpc64-montavista-linux-gnu \
 // RUN:   -analyzer-checker=core,debug.ExprInspection \
 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
Index: cfe/trunk/test/Analysis/ctu-main.c
===
--- cfe/trunk/test/Analysis/ctu-main.c
+++ cfe/trunk/test/Analysis/ctu-main.c
@@ -2,7 +2,7 @@
 // RUN: mkdir -p %t/ctudir2
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu \
 // RUN:   -emit-pch -o %t/ctudir2/ctu-other.c.ast %S/Inputs/ctu-other.c
-// RUN: cp %S/Inputs/ctu-other.c.externalFnMap.txt %t/ctudir2/externalFnMap.txt
+// RUN: cp %S/Inputs/ctu-other.c.externalDefMap.txt %t/ctudir2/externalDefMap.txt
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -std=c89 -analyze \
 // RUN:   -analyzer-checker=core,debug.ExprInspection \
 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
Index: cfe/trunk/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.txt
===
--- cfe/trunk/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.txt
+++ cfe/trunk/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.txt
@@ -0,0 +1,15 @@
+c:@N@chns@F@chf1#I# ctu-other.cpp.ast
+c:@N@myns@N@embed_ns@F@fens#I# ctu-other.cpp.ast
+c:@F@g#I# ctu-other.cpp.ast
+c:@S@mycls@F@fscl#I#S ctu-other.cpp.ast
+c:@S@mycls@F@fcl#I# ctu-other.cpp.ast
+c:@N@myns@S@embed_cls@F@fecl#I# ctu-other.cpp.ast
+c:@S@mycls@S@embed_cls2@F@fecl2#I# ctu-other.cpp.ast
+c:@F@f#I# ctu-other.cpp.ast
+c:@N@myns@F@fns#I# ctu-other.cpp.ast
+c:@F@h#I# ctu-other.cpp.ast
+c:@F@h_chain#I# ctu-chain.cpp.ast
+c:@N@chns@S@chcls@F@chf4#I# ctu-chain.cpp.ast
+c:@N@chns@F@chf2#I# ctu-chain.cpp.ast
+c:@F@fun_using_anon_struct#I# ctu-other.cpp.ast
+c:@F@other_macro_diag#I# ctu-other.cpp.ast
Index: cfe/trunk/test/Analysis/Inputs/ctu-other.c.externalDefMap.txt
===
--- cfe/trunk/test/Analysis/Inputs/ctu-other.c.externalDefMap.txt
+++ cfe/trunk/test/Analysis/Inputs/ctu-other.c.externalDefMap.txt
@@ -0,0 +1,6 @@
+c:@F@inlineAsm ctu-other.c.ast
+c:@F@g ctu-other.c.ast
+c:@F@f ctu-other.c.ast
+c:@F@enumCheck ctu-other.c.ast
+c:@F@identImplicit ctu-other.c.ast
+c:@F@structInProto ctu-other.c.ast
Index: cfe/trunk/test/Analysis/func-mapping-test.cpp
===
--- cfe/trunk/test/Analysis/func-mapping-test.cpp
+++ cfe/tr

[PATCH] D55491: Implement TemplateArgument dumping in terms of Visitor

2019-01-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/AST/ASTDumper.cpp:449-450
+void VisitPackTemplateArgument(const TemplateArgument &TA) {
+  for (TemplateArgument::pack_iterator I = TA.pack_begin(),
+   E = TA.pack_end();
+   I != E; ++I)

steveire wrote:
> aaron.ballman wrote:
> > `llvm::for_each(TA.pack_elements(), ...);` (or a range-based for loop)
> I'm just moving the code as it is in its origin location. You could rewrite 
> it separately if you wish.
I realize that. You're updating existing code, which is a perfectly appropriate 
time for NFC improvements to it -- we make these kinds of requests frequently 
because it's the time at which we notice these minor deficiencies.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55491



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


Re: r350776 - [Sema] Mark target of __attribute__((alias("target"))) used for C

2019-01-10 Thread Nick Desaulniers via cfe-commits
On Thu, Jan 10, 2019 at 7:26 AM Nico Weber  wrote:
>
> Aren't C names sometimes slightly mangled too? For example, on macOS they're 
> prefixed by a _, doesn't that have to be undone there?

Sure, but short of instantiating a demangler in Sema or rewriting how
Clang checks for unused variables, this quickly cuts down on tens of
false negatives when building the Linux kernel with various driver
configurations enabled.  The code review points out this is
suboptimal.

>
> On Wed, Jan 9, 2019 at 6:58 PM Nick Desaulniers via cfe-commits 
>  wrote:
>>
>> Author: nickdesaulniers
>> Date: Wed Jan  9 15:54:55 2019
>> New Revision: 350776
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=350776&view=rev
>> Log:
>> [Sema] Mark target of __attribute__((alias("target"))) used for C
>>
>> Summary:
>> Prevents -Wunneeded-internal-delcaration warnings when the target has no
>> other references. This occurs frequently in device drivers in the Linux
>> kernel.
>>
>> Sema would need to invoke the demangler on the target, since in C++ the
>> target name is mangled:
>>
>> int f() { return 42; }
>> int g() __attribute__((alias("_Z1fv")));
>>
>> Sema does not have the ability to demangle names at this time.
>>
>> https://bugs.llvm.org/show_bug.cgi?id=39088
>> https://github.com/ClangBuiltLinux/linux/issues/232
>>
>> Reviewers: rsmith, rjmccall
>>
>> Reviewed By: rsmith
>>
>> Subscribers: erik.pilkington, cfe-commits, pirama, srhines
>>
>> Differential Revision: https://reviews.llvm.org/D54188
>>
>> Added:
>> cfe/trunk/test/Sema/alias-unused.c
>> Modified:
>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=350776&r1=350775&r2=350776&view=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Jan  9 15:54:55 2019
>> @@ -1898,7 +1898,16 @@ static void handleAliasAttr(Sema &S, Dec
>>  }
>>}
>>
>> -  // FIXME: check if target symbol exists in current file
>> +  // Mark target used to prevent unneeded-internal-declaration warnings.
>> +  if (!S.LangOpts.CPlusPlus) {
>> +// FIXME: demangle Str for C++, as the attribute refers to the mangled
>> +// linkage name, not the pre-mangled identifier.
>> +const DeclarationNameInfo target(&S.Context.Idents.get(Str), 
>> AL.getLoc());
>> +LookupResult LR(S, target, Sema::LookupOrdinaryName);
>> +if (S.LookupQualifiedName(LR, S.getCurLexicalContext()))
>> +  for (NamedDecl *ND : LR)
>> +ND->markUsed(S.Context);
>> +  }
>>
>>D->addAttr(::new (S.Context) AliasAttr(AL.getRange(), S.Context, Str,
>>   
>> AL.getAttributeSpellingListIndex()));
>>
>> Added: cfe/trunk/test/Sema/alias-unused.c
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/alias-unused.c?rev=350776&view=auto
>> ==
>> --- cfe/trunk/test/Sema/alias-unused.c (added)
>> +++ cfe/trunk/test/Sema/alias-unused.c Wed Jan  9 15:54:55 2019
>> @@ -0,0 +1,7 @@
>> +// RUN: %clang_cc1 -triple x86_64-linux-gnu -Wunneeded-internal-declaration 
>> -x c -verify %s
>> +// expected-no-diagnostics
>> +static int f() { return 42; }
>> +int g() __attribute__((alias("f")));
>> +
>> +static int foo [] = { 42, 0xDEAD };
>> +extern typeof(foo) bar __attribute__((unused, alias("foo")));
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



-- 
Thanks,
~Nick Desaulniers
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r350856 - Split -Wdelete-non-virtual-dtor into two groups

2019-01-10 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Thu Jan 10 10:03:07 2019
New Revision: 350856

URL: http://llvm.org/viewvc/llvm-project?rev=350856&view=rev
Log:
Split -Wdelete-non-virtual-dtor into two groups

This group controls two diagnostics: deleting an abstract class with
a non-virtual dtor, which is a guaranteed crash, and deleting a
non-abstract polymorphic class with a non-virtual dtor, which is just
suspicious.

rdar://40380564

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

Added:
cfe/trunk/test/SemaCXX/delete-non-virtual-dtor.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=350856&r1=350855&r2=350856&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Jan 10 10:03:07 2019
@@ -104,7 +104,11 @@ def UndefinedFuncTemplate : DiagGroup<"u
 def MissingNoEscape : DiagGroup<"missing-noescape">;
 
 def DeleteIncomplete : DiagGroup<"delete-incomplete">;
-def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor">;
+def DeleteNonAbstractNonVirtualDtor : 
DiagGroup<"delete-non-abstract-non-virtual-dtor">;
+def DeleteAbstractNonVirtualDtor : 
DiagGroup<"delete-abstract-non-virtual-dtor">;
+def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor",
+ [DeleteNonAbstractNonVirtualDtor,
+  DeleteAbstractNonVirtualDtor]>;
 def AbstractFinalClass : DiagGroup<"abstract-final-class">;
 
 def CXX11CompatDeprecatedWritableStr :

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=350856&r1=350855&r2=350856&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 10 10:03:07 
2019
@@ -6455,12 +6455,12 @@ def warn_non_virtual_dtor : Warning<
 def warn_delete_non_virtual_dtor : Warning<
   "%select{delete|destructor}0 called on non-final %1 that has "
   "virtual functions but non-virtual destructor">,
-  InGroup, DefaultIgnore, ShowInSystemHeader;
+  InGroup, DefaultIgnore, ShowInSystemHeader;
 def note_delete_non_virtual : Note<
   "qualify call to silence this warning">;
 def warn_delete_abstract_non_virtual_dtor : Warning<
   "%select{delete|destructor}0 called on %1 that is abstract but has "
-  "non-virtual destructor">, InGroup, ShowInSystemHeader;
+  "non-virtual destructor">, InGroup, 
ShowInSystemHeader;
 def warn_overloaded_virtual : Warning<
   "%q0 hides overloaded virtual %select{function|functions}1">,
   InGroup, DefaultIgnore;

Added: cfe/trunk/test/SemaCXX/delete-non-virtual-dtor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/delete-non-virtual-dtor.cpp?rev=350856&view=auto
==
--- cfe/trunk/test/SemaCXX/delete-non-virtual-dtor.cpp (added)
+++ cfe/trunk/test/SemaCXX/delete-non-virtual-dtor.cpp Thu Jan 10 10:03:07 2019
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -verify -DDIAG1
+// RUN: %clang_cc1 %s -verify -DDIAG1 -DDIAG2 -Wdelete-non-virtual-dtor
+// RUN: %clang_cc1 %s -verify -DDIAG1 -Wmost 
-Wno-delete-non-abstract-non-virtual-dtor
+// RUN: %clang_cc1 %s -verify -DDIAG2 -Wmost 
-Wno-delete-abstract-non-virtual-dtor
+// RUN: %clang_cc1 %s -verify -Wmost 
-Wno-delete-non-virtual-dtor
+
+#ifndef DIAG1
+#ifndef DIAG2
+// expected-no-diagnostics
+#endif
+#endif
+
+struct S1 {
+  ~S1() {}
+  virtual void abs() = 0;
+};
+
+void f1(S1 *s1) { delete s1; }
+#ifdef DIAG1
+// expected-warning@-2 {{delete called on 'S1' that is abstract but has 
non-virtual destructor}}
+#endif
+
+struct S2 {
+  ~S2() {}
+  virtual void real() {}
+};
+void f2(S2 *s2) { delete s2; }
+#ifdef DIAG2
+// expected-warning@-2 {{delete called on non-final 'S2' that has virtual 
functions but non-virtual destructor}}
+#endif


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


[PATCH] D56405: Split -Wdelete-non-virtual-dtor into two groups

2019-01-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350856: Split -Wdelete-non-virtual-dtor into two groups 
(authored by epilk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56405?vs=180690&id=181081#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D56405

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  test/SemaCXX/delete-non-virtual-dtor.cpp


Index: test/SemaCXX/delete-non-virtual-dtor.cpp
===
--- test/SemaCXX/delete-non-virtual-dtor.cpp
+++ test/SemaCXX/delete-non-virtual-dtor.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -verify -DDIAG1
+// RUN: %clang_cc1 %s -verify -DDIAG1 -DDIAG2 -Wdelete-non-virtual-dtor
+// RUN: %clang_cc1 %s -verify -DDIAG1 -Wmost 
-Wno-delete-non-abstract-non-virtual-dtor
+// RUN: %clang_cc1 %s -verify -DDIAG2 -Wmost 
-Wno-delete-abstract-non-virtual-dtor
+// RUN: %clang_cc1 %s -verify -Wmost 
-Wno-delete-non-virtual-dtor
+
+#ifndef DIAG1
+#ifndef DIAG2
+// expected-no-diagnostics
+#endif
+#endif
+
+struct S1 {
+  ~S1() {}
+  virtual void abs() = 0;
+};
+
+void f1(S1 *s1) { delete s1; }
+#ifdef DIAG1
+// expected-warning@-2 {{delete called on 'S1' that is abstract but has 
non-virtual destructor}}
+#endif
+
+struct S2 {
+  ~S2() {}
+  virtual void real() {}
+};
+void f2(S2 *s2) { delete s2; }
+#ifdef DIAG2
+// expected-warning@-2 {{delete called on non-final 'S2' that has virtual 
functions but non-virtual destructor}}
+#endif
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -104,7 +104,11 @@
 def MissingNoEscape : DiagGroup<"missing-noescape">;
 
 def DeleteIncomplete : DiagGroup<"delete-incomplete">;
-def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor">;
+def DeleteNonAbstractNonVirtualDtor : 
DiagGroup<"delete-non-abstract-non-virtual-dtor">;
+def DeleteAbstractNonVirtualDtor : 
DiagGroup<"delete-abstract-non-virtual-dtor">;
+def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor",
+ [DeleteNonAbstractNonVirtualDtor,
+  DeleteAbstractNonVirtualDtor]>;
 def AbstractFinalClass : DiagGroup<"abstract-final-class">;
 
 def CXX11CompatDeprecatedWritableStr :
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6455,12 +6455,12 @@
 def warn_delete_non_virtual_dtor : Warning<
   "%select{delete|destructor}0 called on non-final %1 that has "
   "virtual functions but non-virtual destructor">,
-  InGroup, DefaultIgnore, ShowInSystemHeader;
+  InGroup, DefaultIgnore, ShowInSystemHeader;
 def note_delete_non_virtual : Note<
   "qualify call to silence this warning">;
 def warn_delete_abstract_non_virtual_dtor : Warning<
   "%select{delete|destructor}0 called on %1 that is abstract but has "
-  "non-virtual destructor">, InGroup, ShowInSystemHeader;
+  "non-virtual destructor">, InGroup, 
ShowInSystemHeader;
 def warn_overloaded_virtual : Warning<
   "%q0 hides overloaded virtual %select{function|functions}1">,
   InGroup, DefaultIgnore;


Index: test/SemaCXX/delete-non-virtual-dtor.cpp
===
--- test/SemaCXX/delete-non-virtual-dtor.cpp
+++ test/SemaCXX/delete-non-virtual-dtor.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -verify -DDIAG1
+// RUN: %clang_cc1 %s -verify -DDIAG1 -DDIAG2 -Wdelete-non-virtual-dtor
+// RUN: %clang_cc1 %s -verify -DDIAG1 -Wmost -Wno-delete-non-abstract-non-virtual-dtor
+// RUN: %clang_cc1 %s -verify -DDIAG2 -Wmost -Wno-delete-abstract-non-virtual-dtor
+// RUN: %clang_cc1 %s -verify -Wmost -Wno-delete-non-virtual-dtor
+
+#ifndef DIAG1
+#ifndef DIAG2
+// expected-no-diagnostics
+#endif
+#endif
+
+struct S1 {
+  ~S1() {}
+  virtual void abs() = 0;
+};
+
+void f1(S1 *s1) { delete s1; }
+#ifdef DIAG1
+// expected-warning@-2 {{delete called on 'S1' that is abstract but has non-virtual destructor}}
+#endif
+
+struct S2 {
+  ~S2() {}
+  virtual void real() {}
+};
+void f2(S2 *s2) { delete s2; }
+#ifdef DIAG2
+// expected-warning@-2 {{delete called on non-final 'S2' that has virtual functions but non-virtual destructor}}
+#endif
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -104,7 +104,11 @@
 def MissingNoEscape : DiagGroup<"missing-noescape">;
 
 def DeleteIncomplete : DiagGroup<"delete-incomplete">;
-def DeleteNonVirtualDtor : DiagGroup<"delete-

[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a reviewer: ilya-biryukov.
sammccall added a comment.

In D56444#1351714 , @JonasToth wrote:

> @sammccall I (hopefully) fixed the type-issue in my test-cases. They 
> nevertheless fail both on me, on latest llvm+clang+your patch. Clang-tidy 
> still the same, so maybe there is a difference in our builds?
>  Do you build with assertions on?
>  I work on linux, ubuntu 18.04, building with clang-6.0, maybe there is a 
> difference?


Your tests indeed fail (I was rebuilding `AnalysisTests` instead of 
`ClangAnalysisTests`, oops!).
The `// namespace std` comments out the rest of the test, because the test 
contains no newlines. Try using raw strings instead :-)
After removing the comments, the tests pass.

In D56444#1351257 , @steveire wrote:

> I believe I have a solution to this, but this is not the place to discuss it. 
> We can discuss it when I propose that patch :). I'll be sure to add you to 
> the review.


Understood, looking forward to hearing it! It would certainly be nice if there 
was a way to run matchers over a simpler/more consistent AST when appropriate.

@aaron.ballman @JonasToth I think this is ready for review again :-)


Repository:
  rC Clang

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

https://reviews.llvm.org/D56444



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


[PATCH] D56552: [clang-tidy] update FunctionSizeCheck for D56444

2019-01-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: JonasToth, aaron.ballman.
Herald added subscribers: cfe-commits, xazax.hun.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56552

Files:
  clang-tidy/readability/FunctionSizeCheck.cpp


Index: clang-tidy/readability/FunctionSizeCheck.cpp
===
--- clang-tidy/readability/FunctionSizeCheck.cpp
+++ clang-tidy/readability/FunctionSizeCheck.cpp
@@ -145,7 +145,12 @@
 }
 
 void FunctionSizeCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(functionDecl(unless(isInstantiated())).bind("func"), 
this);
+  // Lambdas ignored - historically considered part of enclosing function.
+  // FIXME: include them instead? Top-level lambdas are currently never 
counted.
+  Finder->addMatcher(functionDecl(unless(isInstantiated()),
+  unless(cxxMethodDecl(ofClass(isLambda()
+ .bind("func"),
+ this);
 }
 
 void FunctionSizeCheck::check(const MatchFinder::MatchResult &Result) {


Index: clang-tidy/readability/FunctionSizeCheck.cpp
===
--- clang-tidy/readability/FunctionSizeCheck.cpp
+++ clang-tidy/readability/FunctionSizeCheck.cpp
@@ -145,7 +145,12 @@
 }
 
 void FunctionSizeCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(functionDecl(unless(isInstantiated())).bind("func"), this);
+  // Lambdas ignored - historically considered part of enclosing function.
+  // FIXME: include them instead? Top-level lambdas are currently never counted.
+  Finder->addMatcher(functionDecl(unless(isInstantiated()),
+  unless(cxxMethodDecl(ofClass(isLambda()
+ .bind("func"),
+ this);
 }
 
 void FunctionSizeCheck::check(const MatchFinder::MatchResult &Result) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

(Sorry, I forgot to mention: the corresponding clang-tidy fix is in D56552 
 - I didn't manage to switch to monorepo yet 
:-/)


Repository:
  rC Clang

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

https://reviews.llvm.org/D56444



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


r350858 - [analyzer] [NFC] Track object type with ArgEffect in RetainCountChecker.

2019-01-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jan 10 10:13:59 2019
New Revision: 350858

URL: http://llvm.org/viewvc/llvm-project?rev=350858&view=rev
Log:
[analyzer] [NFC] Track object type with ArgEffect in RetainCountChecker.

This would be needed in the future.

https://reviews.llvm.org/D56040

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp

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

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

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

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h?rev=350858&r1=350857&r2=350858&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h Thu Jan 
10 10:13:59 2019
@@ -52,9 +52,7 @@ enum class ObjKind {
   OS
 };
 
-/// An ArgEffect summarizes the retain count behavior on an argument or 
receiver
-/// to a function or method.
-enum ArgEffect {
+enum ArgEffectKind {
   /// There is no effect.
   DoNothing,
 
@@ -133,6 +131,27 @@ enum ArgEffect {
   DecRefMsgAndStopTrackingHard
 };
 
+/// An ArgEffect summarizes the retain count behavior on an argument or 
receiver
+/// to a function or method.
+class ArgEffect {
+  ArgEffectKind K;
+  ObjKind O;
+public:
+  explicit ArgEffect(ArgEffectKind K = DoNothing, ObjKind O = ObjKind::AnyObj)
+  : K(K), O(O) {}
+
+  ArgEffectKind getKind() const { return K; }
+  ObjKind getObjKind() const { return O; }
+
+  ArgEffect withKind(ArgEffectKind NewK) {
+return ArgEffect(NewK, O);
+  }
+
+  bool operator==(const ArgEffect &Other) const {
+return K == Other.K && O == Other.O;
+  }
+};
+
 /// RetEffect summarizes a call's retain/release behavior with respect
 /// to its return value.
 class RetEffect {
@@ -218,7 +237,9 @@ class CallEffects {
   RetEffect Ret;
   ArgEffect Receiver;
 
-  CallEffects(const RetEffect &R) : Ret(R) {}
+  CallEffects(const RetEffect &R,
+  ArgEffect Receiver = ArgEffect(DoNothing, ObjKind::AnyObj))
+  : Ret(R), Receiver(Receiver) {}
 
 public:
   /// Returns the argument effects for a call.
@@ -263,7 +284,8 @@ namespace llvm {
 
 template <> struct FoldingSetTrait {
 static inline void Profile(const ArgEffect X, FoldingSetNodeID &ID) {
-  ID.AddInteger((unsigned) X);
+  ID.AddInteger((unsigned) X.getKind());
+  ID.AddInteger((unsigned) X.getObjKind());
 }
 };
 template <> struct FoldingSetTrait {
@@ -377,8 +399,8 @@ public:
   void setThisEffect(ArgEffect e) { This = e; }
 
   bool isNoop() const {
-return Ret == RetEffect::MakeNoRet() && Receiver == DoNothing
-  && DefaultArgEffect == MayEscape && This == DoNothing
+return Ret == RetEffect::MakeNoRet() && Receiver.getKind() == DoNothing
+  && DefaultArgEffect.getKind() == MayEscape && This.getKind() == DoNothing
   && Args.isEmpty();
   }
 
@@ -547,32 +569,31 @@ class RetainSummaryManager {
 
   const RetainSummary *getPersistentSummary(const RetainSummary &OldSumm);
 
-  const RetainSummary *getPersistentSummary(RetEffect RetEff,
-ArgEffects ScratchArgs,
-ArgEffect ReceiverEff = DoNothing,
-ArgEffect DefaultEff = MayEscape,
-ArgEffect ThisEff = DoNothing) {
-RetainSummary Summ(ScratchArgs, RetEff, DefaultEff, ReceiverEff,
-   ThisEff);
+  const RetainSummary *
+  getPersistentSummary(RetEffect RetEff, ArgEffects ScratchArgs,
+   ArgEffect ReceiverEff = ArgEffect(DoNothing),
+   ArgEffect DefaultEff = ArgEffect(MayEscape),
+   ArgEffect ThisEff = ArgEffect(DoNothing)) {
+RetainSummary Summ(ScratchArgs, RetEff, DefaultEff, ReceiverEff, ThisEff);
 return getPersistentSummary(Summ);
   }
 
   const RetainSummary *getDoNothingSummary() {
 return getPersistentSummary(RetEffect::MakeNoRet(),
 ArgEffects(AF.getEmptyMap()),
-DoNothing, DoNothing);
+ArgEffect(DoNothing), ArgEffect(DoNothing));
   }
 
   const RetainSummary *getDefaultSummary() {
 return getPersistentSummary(RetEffect::MakeNoRet(),
 ArgEffects(AF.getEmptyMap()),
-DoNothing, MayEscape);
+ArgEffect(DoNothing), ArgEffect(MayEscape));
   }
 
   const RetainSummary *getPersistentStopSummary() {
-return 

r350857 - [analyzer] [NFC] Move ObjKind into a separate top-level enum in RetainSummaryManager.

2019-01-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jan 10 10:13:46 2019
New Revision: 350857

URL: http://llvm.org/viewvc/llvm-project?rev=350857&view=rev
Log:
[analyzer] [NFC] Move ObjKind into a separate top-level enum in 
RetainSummaryManager.

Allows using it in future outside of RetEffect.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp

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

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

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

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h?rev=350857&r1=350856&r2=350857&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h Thu Jan 
10 10:13:46 2019
@@ -36,6 +36,22 @@ using namespace ento;
 namespace clang {
 namespace ento {
 
+/// Determines the object kind of a tracked object.
+enum class ObjKind {
+  /// Indicates that the tracked object is a CF object.  This is
+  /// important between GC and non-GC code.
+  CF,
+  /// Indicates that the tracked object is an Objective-C object.
+  ObjC,
+  /// Indicates that the tracked object could be a CF or Objective-C object.
+  AnyObj,
+  /// Indicates that the tracked object is a generalized object.
+  Generalized,
+
+  /// A descendant of OSObject.
+  OS
+};
+
 /// An ArgEffect summarizes the retain count behavior on an argument or 
receiver
 /// to a function or method.
 enum ArgEffect {
@@ -144,27 +160,12 @@ public:
 NoRetHard
   };
 
-  /// Determines the object kind of a tracked object.
-  enum ObjKind {
-/// Indicates that the tracked object is a CF object.  This is
-/// important between GC and non-GC code.
-CF,
-/// Indicates that the tracked object is an Objective-C object.
-ObjC,
-/// Indicates that the tracked object could be a CF or Objective-C object.
-AnyObj,
-/// Indicates that the tracked object is a generalized object.
-Generalized,
-
-/// A descendant of OSObject.
-OS
-  };
 
 private:
   Kind K;
   ObjKind O;
 
-  RetEffect(Kind k, ObjKind o = AnyObj) : K(k), O(o) {}
+  RetEffect(Kind k, ObjKind o = ObjKind::AnyObj) : K(k), O(o) {}
 
 public:
   Kind getKind() const { return K; }
@@ -184,7 +185,7 @@ public:
   }
 
   static RetEffect MakeOwnedWhenTrackedReceiver() {
-return RetEffect(OwnedWhenTrackedReceiver, ObjC);
+return RetEffect(OwnedWhenTrackedReceiver, ObjKind::ObjC);
   }
 
   static RetEffect MakeOwned(ObjKind o) {
@@ -194,7 +195,7 @@ public:
 return RetEffect(NotOwnedSymbol, o);
   }
   static RetEffect MakeGCNotOwned() {
-return RetEffect(GCNotOwnedSymbol, ObjC);
+return RetEffect(GCNotOwnedSymbol, ObjKind::ObjC);
   }
   static RetEffect MakeNoRet() {
 return RetEffect(NoRet);
@@ -659,9 +660,9 @@ public:
  TrackObjCAndCFObjects(trackObjCAndCFObjects),
  TrackOSObjects(trackOSObjects),
  AF(BPAlloc),
- ObjCAllocRetE(usesARC ? RetEffect::MakeNotOwned(RetEffect::ObjC)
-   : RetEffect::MakeOwned(RetEffect::ObjC)),
- ObjCInitRetE(usesARC ? RetEffect::MakeNotOwned(RetEffect::ObjC)
+ ObjCAllocRetE(usesARC ? RetEffect::MakeNotOwned(ObjKind::ObjC)
+   : RetEffect::MakeOwned(ObjKind::ObjC)),
+ ObjCInitRetE(usesARC ? RetEffect::MakeNotOwned(ObjKind::ObjC)
: RetEffect::MakeOwnedWhenTrackedReceiver()) {
 InitializeClassMethodSummaries();
 InitializeMethodSummaries();

Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=350857&r1=350856&r2=350857&view=diff
==
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Thu Jan 10 10:13:46 2019
@@ -1460,14 +1460,14 @@ void ObjCMigrateASTConsumer::AddCFAnnota
   if (!ResultAnnotated) {
 RetEffect Ret = CE.getReturnValue();
 const char *AnnotationString = nullptr;
-if (Ret.getObjKind() == RetEffect::CF) {
+if (Ret.getObjKind() == ObjKind::CF) {
   if (Ret.isOwned() && NSAPIObj->isMacroDefined("CF_RETURNS_RETAINED"))
 AnnotationString = " CF_RETURNS_RETAINED";
   else if (Ret.notOwned() &&
NSAPIObj->isMacroDefined("CF_RETURNS_NOT_RETAINED"))
 AnnotationString = " CF_RETURNS_NOT_RETAINED";
 }
-else if (Ret.getObjKind() == RetEffect::ObjC) {
+else if (Ret.getObjKind() 

r350859 - [analyzer] [RetainCountChecker] [NFC] Remove redundant enum items *Msg, as the object type is already communicated by a separate field

2019-01-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jan 10 10:14:12 2019
New Revision: 350859

URL: http://llvm.org/viewvc/llvm-project?rev=350859&view=rev
Log:
[analyzer] [RetainCountChecker] [NFC] Remove redundant enum items *Msg, as the 
object type is already communicated by a separate field

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp

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

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h?rev=350859&r1=350858&r2=350859&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h Thu Jan 
10 10:14:12 2019
@@ -68,21 +68,11 @@ enum ArgEffectKind {
   /// if CFRelease has been called on the argument.
   DecRef,
 
-  /// The argument has its reference count decreased by 1.  This is as
-  /// if a -release message has been sent to the argument.  This differs
-  /// in behavior from DecRef when ARC is enabled.
-  DecRefMsg,
-
   /// The argument has its reference count decreased by 1 to model
   /// a transferred bridge cast under ARC.
   DecRefBridgedTransferred,
 
   /// The argument has its reference count increased by 1.  This is as
-  /// if a -retain message has been sent to the argument.  This differs
-  /// in behavior from IncRef when ARC is enabled.
-  IncRefMsg,
-
-  /// The argument has its reference count increased by 1.  This is as
   /// if CFRetain has been called on the argument.
   IncRef,
 
@@ -122,13 +112,6 @@ enum ArgEffectKind {
   /// count of the argument and all typestate tracking on that argument
   /// should cease.
   DecRefAndStopTrackingHard,
-
-  /// Performs the combined functionality of DecRefMsg and StopTrackingHard.
-  ///
-  /// The models the effect that the called function decrements the reference
-  /// count of the argument and all typestate tracking on that argument
-  /// should cease.
-  DecRefMsgAndStopTrackingHard
 };
 
 /// An ArgEffect summarizes the retain count behavior on an argument or 
receiver

Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=350859&r1=350858&r2=350859&view=diff
==
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Thu Jan 10 10:14:12 2019
@@ -1484,14 +1484,15 @@ void ObjCMigrateASTConsumer::AddCFAnnota
pe = FuncDecl->param_end(); pi != pe; ++pi, ++i) {
 const ParmVarDecl *pd = *pi;
 ArgEffect AE = AEArgs[i];
-if (AE.getKind() == DecRef && !pd->hasAttr() &&
+if (AE.getKind() == DecRef && AE.getObjKind() == ObjKind::CF &&
+!pd->hasAttr() &&
 NSAPIObj->isMacroDefined("CF_CONSUMED")) {
   edit::Commit commit(*Editor);
   commit.insertBefore(pd->getLocation(), "CF_CONSUMED ");
   Editor->commit(commit);
-}
-else if (AE.getKind() == DecRefMsg && !pd->hasAttr() &&
- NSAPIObj->isMacroDefined("NS_CONSUMED")) {
+} else if (AE.getKind() == DecRef && AE.getObjKind() == ObjKind::ObjC &&
+   !pd->hasAttr() &&
+   NSAPIObj->isMacroDefined("NS_CONSUMED")) {
   edit::Commit commit(*Editor);
   commit.insertBefore(pd->getLocation(), "NS_CONSUMED ");
   Editor->commit(commit);
@@ -1536,8 +1537,8 @@ ObjCMigrateASTConsumer::CF_BRIDGING_KIND
pe = FuncDecl->param_end(); pi != pe; ++pi, ++i) {
 const ParmVarDecl *pd = *pi;
 ArgEffect AE = AEArgs[i];
-if (AE.getKind() == DecRef /*CFConsumed annotated*/ ||
-AE.getKind() == IncRef) {
+if ((AE.getKind() == DecRef /*CFConsumed annotated*/ ||
+ AE.getKind() == IncRef) && AE.getObjKind() == ObjKind::CF) {
   if (AE.getKind() == DecRef && !pd->hasAttr())
 ArgCFAudited = true;
   else if (AE.getKind() == IncRef)
@@ -1610,7 +1611,9 @@ void ObjCMigrateASTConsumer::AddCFAnnota
pe = MethodDecl->param_end(); pi != pe; ++pi, ++i) {
 const ParmVarDecl *pd = *pi;
 ArgEffect AE = AEArgs[i];
-if (AE.getKind() == DecRef && !pd->hasAttr() &&
+if (AE.getKind() == DecRef
+&& AE.getObjKind() == ObjKind::CF
+&& !pd->hasAttr() &&
 NSAPIObj->isMacroDefined("CF_CONSUMED")) {
   edit::Commit commit(*Editor);
   commit.insertBefore(pd->getLocation(), "CF_CONSUMED ");
@@ -1633,7 +1636,7 @@ void ObjCMigrateASTConsumer::migrateAddM
MethodDecl->hasAttr() ||
MethodDecl->h

r350861 - [analyzer] [RetainCountChecker] Remove redundant enum UnarySummaryKind

2019-01-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jan 10 10:14:38 2019
New Revision: 350861

URL: http://llvm.org/viewvc/llvm-project?rev=350861&view=rev
Log:
[analyzer] [RetainCountChecker] Remove redundant enum UnarySummaryKind

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h?rev=350861&r1=350860&r2=350861&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h Thu Jan 
10 10:14:38 2019
@@ -537,10 +537,8 @@ class RetainSummaryManager {
   /// Free the OS object.
   const RetainSummary *getOSSummaryFreeRule(const FunctionDecl *FD);
 
-  enum UnaryFuncKind { cfretain, cfrelease, cfautorelease, cfmakecollectable };
-
   const RetainSummary *getUnarySummary(const FunctionType* FT,
-   UnaryFuncKind func);
+   ArgEffectKind AE);
 
   const RetainSummary *getCFSummaryCreateRule(const FunctionDecl *FD);
   const RetainSummary *getCFSummaryGetRule(const FunctionDecl *FD);

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp?rev=350861&r1=350860&r2=350861&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp Thu Jan 10 
10:14:38 2019
@@ -194,7 +194,7 @@ const RetainSummary *RetainSummaryManage
   } else if(FName == "NSMakeCollectable") {
 // Handle: id NSMakeCollectable(CFTypeRef)
 AllowAnnotations = false;
-return RetTy->isObjCIdType() ? getUnarySummary(FT, cfmakecollectable)
+return RetTy->isObjCIdType() ? getUnarySummary(FT, DoNothing)
  : getPersistentStopSummary();
   } else if (FName == "CMBufferQueueDequeueAndRetain" ||
  FName == "CMBufferQueueDequeueIfDataReadyAndRetain") {
@@ -307,16 +307,16 @@ const RetainSummary *RetainSummaryManage
 // We want to ignore such annotation.
 AllowAnnotations = false;
 
-return getUnarySummary(FT, cfretain);
+return getUnarySummary(FT, IncRef);
   } else if (isAutorelease(FD, FName)) {
 // The headers use cf_consumed, but we can fully model CFAutorelease
 // ourselves.
 AllowAnnotations = false;
 
-return getUnarySummary(FT, cfautorelease);
+return getUnarySummary(FT, Autorelease);
   } else if (isMakeCollectable(FName)) {
 AllowAnnotations = false;
-return getUnarySummary(FT, cfmakecollectable);
+return getUnarySummary(FT, DoNothing);
   } else {
 return getCFCreateGetRuleSummary(FD);
   }
@@ -326,7 +326,7 @@ const RetainSummary *RetainSummaryManage
 if (cocoa::isRefType(RetTy, "CG", FName) ||
 cocoa::isRefType(RetTy, "CV", FName)) {
   if (isRetain(FD, FName))
-return getUnarySummary(FT, cfretain);
+return getUnarySummary(FT, IncRef);
   else
 return getCFCreateGetRuleSummary(FD);
 }
@@ -350,7 +350,7 @@ const RetainSummary *RetainSummaryManage
 FName = FName.substr(FName.startswith("CGCF") ? 4 : 2);
 
 if (isRelease(FD, FName))
-  return getUnarySummary(FT, cfrelease);
+  return getUnarySummary(FT, DecRef);
 else {
   assert(ScratchArgs.isEmpty());
   // Remaining CoreFoundation and CoreGraphics functions.
@@ -644,11 +644,9 @@ RetainSummaryManager::canEval(const Call
   return None;
 }
 
-// TODO: UnaryFuncKind is a very funny enum, it really should not exist:
-// just pass the needed effect directly!
 const RetainSummary *
 RetainSummaryManager::getUnarySummary(const FunctionType* FT,
-  UnaryFuncKind func) {
+  ArgEffectKind AE) {
 
   // Unary functions have no arg effects by definition.
   ArgEffects ScratchArgs(AF.getEmptyMap());
@@ -659,13 +657,7 @@ RetainSummaryManager::getUnarySummary(co
   if (!FTP || FTP->getNumParams() != 1)
 return getPersistentStopSummary();
 
-  ArgEffect Effect(DoNothing, ObjKind::CF);
-  switch (func) {
-  case cfretain: Effect = Effect.withKind(IncRef); break;
-  case cfrelease: Effect = Effect.withKind(DecRef); break;
-  case cfautorelease: Effect = Effect.withKind(Autorelease); break;
-  case cfmakecollectable: Effect = Effect.withKind(DoNothing); break;
-  }
+  ArgEffect Effect(AE, ObjKind::CF);
 
   ScratchArgs = AF.add(ScratchArgs, 0, Effect);
   ret

r350862 - [analyzer] [RetainCountChecker] [NFC] Refactor the way attributes are handled

2019-01-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jan 10 10:14:51 2019
New Revision: 350862

URL: http://llvm.org/viewvc/llvm-project?rev=350862&view=rev
Log:
[analyzer] [RetainCountChecker] [NFC] Refactor the way attributes are handled

Make sure all checks for attributes go through a centralized function,
which checks whether attribute handling is enabled, and performs
validation.  The type of the attribute is returned.

Sadly, metaprogramming is required as attributes have no sensible static
getters.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h?rev=350862&r1=350861&r2=350862&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h Thu Jan 
10 10:14:51 2019
@@ -741,16 +741,18 @@ public:
 
   RetEffect getObjAllocRetEffect() const { return ObjCAllocRetE; }
 
-  /// \return True if the declaration has an attribute {@code T},
-  /// AND we are tracking that attribute. False otherwise.
+  /// Determine whether a declaration {@code D} of correspondent type (return
+  /// type for functions/methods) {@code QT} has any of the given attributes,
+  /// provided they pass necessary validation checks AND tracking the given
+  /// attribute is enabled.
+  /// Returns the object kind corresponding to the present attribute, or None,
+  /// if none of the specified attributes are present.
+  /// Crashes if passed an attribute which is not explicitly handled.
   template 
-  bool hasEnabledAttr(const Decl *D) {
-return isAttrEnabled() && D->hasAttr();
-  }
+  Optional hasAnyEnabledAttrOf(const Decl *D, QualType QT);
 
-  /// Check whether we are tracking properties specified by the attributes.
-  template 
-  bool isAttrEnabled();
+  template 
+  Optional hasAnyEnabledAttrOf(const Decl *D, QualType QT);
 
   friend class RetainSummaryTemplate;
 };

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp?rev=350862&r1=350861&r2=350862&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp Thu Jan 10 
10:14:51 2019
@@ -36,17 +36,79 @@ constexpr static bool isOneOf() {
   return std::is_same::value || isOneOf();
 }
 
-template  bool RetainSummaryManager::isAttrEnabled() {
+namespace {
+
+struct GeneralizedReturnsRetainedAttr {
+  static bool classof(const Attr *A) {
+if (auto AA = dyn_cast(A))
+  return AA->getAnnotation() == "rc_ownership_returns_retained";
+return false;
+  }
+};
+
+struct GeneralizedReturnsNotRetainedAttr {
+  static bool classof(const Attr *A) {
+if (auto AA = dyn_cast(A))
+  return AA->getAnnotation() == "rc_ownership_returns_not_retained";
+return false;
+  }
+};
+
+struct GeneralizedConsumedAttr {
+  static bool classof(const Attr *A) {
+if (auto AA = dyn_cast(A))
+  return AA->getAnnotation() == "rc_ownership_consumed";
+return false;
+  }
+};
+
+}
+
+template 
+Optional RetainSummaryManager::hasAnyEnabledAttrOf(const Decl *D,
+QualType QT) {
+  ObjKind K;
   if (isOneOf()) {
-return TrackObjCAndCFObjects;
+  CFReturnsNotRetainedAttr>()) {
+if (!TrackObjCAndCFObjects)
+  return None;
+
+K = ObjKind::CF;
+  } else if (isOneOf()) {
+
+if (!TrackObjCAndCFObjects)
+  return None;
+
+if (isOneOf() &&
+!cocoa::isCocoaObjectRef(QT))
+  return None;
+K = ObjKind::ObjC;
   } else if (isOneOf()) {
-return TrackOSObjects;
+if (!TrackOSObjects)
+  return None;
+K = ObjKind::OS;
+  } else if (isOneOf()) {
+K = ObjKind::Generalized;
+  } else {
+llvm_unreachable("Unexpected attribute");
   }
-  llvm_unreachable("Unexpected attribute passed");
+  if (D->hasAttr())
+return K;
+  return None;
+}
+
+template 
+Optional RetainSummaryManager::hasAnyEnabledAttrOf(const Decl *D,
+QualType QT) {
+  if (auto Out = hasAnyEnabledAttrOf(D, QT))
+return Out;
+  return hasAnyEnabledAttrOf(D, QT);
 }
 
 const RetainSummary *
@@ -727,33 +789,18 @@ RetainSummaryManager::getCFSummaryGetRul
 Optional
 RetainSummaryManager::getRetEffectFromAnnotations(QualType RetTy,
   const Decl *D) {
-  if (TrackObjCAndCFObjects && cocoa::isCocoaObjectRef(RetTy)) {
-if

r350863 - [analyzer] [RetainCountChecker] [NFC] Another minor cleanup

2019-01-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jan 10 10:15:04 2019
New Revision: 350863

URL: http://llvm.org/viewvc/llvm-project?rev=350863&view=rev
Log:
[analyzer] [RetainCountChecker] [NFC] Another minor cleanup

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h?rev=350863&r1=350862&r2=350863&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h Thu Jan 
10 10:15:04 2019
@@ -38,17 +38,20 @@ namespace ento {
 
 /// Determines the object kind of a tracked object.
 enum class ObjKind {
-  /// Indicates that the tracked object is a CF object.  This is
-  /// important between GC and non-GC code.
+  /// Indicates that the tracked object is a CF object.
   CF,
+
   /// Indicates that the tracked object is an Objective-C object.
   ObjC,
+
   /// Indicates that the tracked object could be a CF or Objective-C object.
   AnyObj,
+
   /// Indicates that the tracked object is a generalized object.
   Generalized,
 
-  /// A descendant of OSObject.
+  /// Indicates that the tracking object is a descendant of a
+  /// referenced-counted OSObject, used in the Darwin kernel.
   OS
 };
 
@@ -60,20 +63,17 @@ enum ArgEffectKind {
   /// the referenced object.
   Autorelease,
 
-  /// The argument is treated as if an -dealloc message had been sent to
-  /// the referenced object.
+  /// The argument is treated as if the referenced object was deallocated.
   Dealloc,
 
-  /// The argument has its reference count decreased by 1.  This is as
-  /// if CFRelease has been called on the argument.
+  /// The argument has its reference count decreased by 1.
   DecRef,
 
   /// The argument has its reference count decreased by 1 to model
   /// a transferred bridge cast under ARC.
   DecRefBridgedTransferred,
 
-  /// The argument has its reference count increased by 1.  This is as
-  /// if CFRetain has been called on the argument.
+  /// The argument has its reference count increased by 1.
   IncRef,
 
   /// The argument is a pointer to a retain-counted object; on exit, the new
@@ -139,18 +139,19 @@ public:
 /// Indicates that no retain count information is tracked for
 /// the return value.
 NoRet,
+
 /// Indicates that the returned value is an owned (+1) symbol.
 OwnedSymbol,
+
 /// Indicates that the returned value is an object with retain count
 /// semantics but that it is not owned (+0).  This is the default
 /// for getters, etc.
 NotOwnedSymbol,
-/// Indicates that the object is not owned and controlled by the
-/// Garbage collector.
-GCNotOwnedSymbol,
+
 /// Indicates that the return value is an owned object when the
 /// receiver is also a tracked object.
 OwnedWhenTrackedReceiver,
+
 // Treat this function as returning a non-tracked symbol even if
 // the function has been inlined. This is used where the call
 // site summary is more precise than the summary indirectly produced
@@ -158,7 +159,6 @@ public:
 NoRetHard
   };
 
-
 private:
   Kind K;
   ObjKind O;
@@ -192,9 +192,6 @@ public:
   static RetEffect MakeNotOwned(ObjKind o) {
 return RetEffect(NotOwnedSymbol, o);
   }
-  static RetEffect MakeGCNotOwned() {
-return RetEffect(GCNotOwnedSymbol, ObjKind::ObjC);
-  }
   static RetEffect MakeNoRet() {
 return RetEffect(NoRet);
   }
@@ -372,6 +369,7 @@ public:
   ArgEffect getReceiverEffect() const { return Receiver; }
 
   /// \return the effect on the "this" receiver of the method call.
+  /// This is only meaningful if the summary applies to CXXMethodDecl*.
   ArgEffect getThisEffect() const { return This; }
 
   /// Set the effect of the method on "this".

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp?rev=350863&r1=350862&r2=350863&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp Thu Jan 10 
10:15:04 2019
@@ -38,6 +38,7 @@ constexpr static bool isOneOf() {
 
 namespace {
 
+/// Fake attribute class for RC* attributes.
 struct GeneralizedReturnsRetainedAttr {
   static bool classof(const Attr *A) {
 if (auto AA = dyn_cast(A))


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


r350860 - [analyzer] [RetainCountChecker] Remove obsolete "MakeCollectable" enum value

2019-01-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jan 10 10:14:25 2019
New Revision: 350860

URL: http://llvm.org/viewvc/llvm-project?rev=350860&view=rev
Log:
[analyzer] [RetainCountChecker] Remove obsolete "MakeCollectable" enum value

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h

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

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h?rev=350860&r1=350859&r2=350860&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h Thu Jan 
10 10:14:25 2019
@@ -76,10 +76,6 @@ enum ArgEffectKind {
   /// if CFRetain has been called on the argument.
   IncRef,
 
-  /// The argument acts as if has been passed to CFMakeCollectable, which
-  /// transfers the object to the Garbage Collector under GC.
-  MakeCollectable,
-
   /// The argument is a pointer to a retain-counted object; on exit, the new
   /// value of the pointer is a +0 value or NULL.
   UnretainedOutParameter,

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=350860&r1=350859&r2=350860&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
Thu Jan 10 10:14:25 2019
@@ -730,8 +730,6 @@ ProgramStateRef RetainCountChecker::upda
   break;
 }
   }
-  if (AE.getKind() == MakeCollectable)
-AE = AE.withKind(DoNothing);
 
   // Handle all use-after-releases.
   if (V.getKind() == RefVal::Released) {
@@ -741,9 +739,6 @@ ProgramStateRef RetainCountChecker::upda
   }
 
   switch (AE.getKind()) {
-case MakeCollectable:
-  llvm_unreachable("MakeCollectable already converted");
-
 case UnretainedOutParameter:
 case RetainedOutParameter:
   llvm_unreachable("Applies to pointer-to-pointer parameters, which should 
"

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp?rev=350860&r1=350859&r2=350860&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp Thu Jan 10 
10:14:25 2019
@@ -457,7 +457,6 @@ static ArgEffect getStopTrackingHardEqui
   case Autorelease:
   case DecRefBridgedTransferred:
   case IncRef:
-  case MakeCollectable:
   case UnretainedOutParameter:
   case RetainedOutParameter:
   case MayEscape:
@@ -665,7 +664,7 @@ RetainSummaryManager::getUnarySummary(co
   case cfretain: Effect = Effect.withKind(IncRef); break;
   case cfrelease: Effect = Effect.withKind(DecRef); break;
   case cfautorelease: Effect = Effect.withKind(Autorelease); break;
-  case cfmakecollectable: Effect = Effect.withKind(MakeCollectable); break;
+  case cfmakecollectable: Effect = Effect.withKind(DoNothing); break;
   }
 
   ScratchArgs = AF.add(ScratchArgs, 0, Effect);


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


r350865 - [analyzer] [NFC] Reduce redundancy in RetainSummaryManager by using a function

2019-01-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jan 10 10:15:30 2019
New Revision: 350865

URL: http://llvm.org/viewvc/llvm-project?rev=350865&view=rev
Log:
[analyzer] [NFC] Reduce redundancy in RetainSummaryManager by using a function

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h?rev=350865&r1=350864&r2=350865&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h Thu Jan 
10 10:15:30 2019
@@ -641,10 +641,9 @@ class RetainSummaryManager {
   /// Apply the annotation of {@code pd} in function {@code FD}
   /// to the resulting summary stored in out-parameter {@code Template}.
   /// \return whether an annotation was applied.
-  bool applyFunctionParamAnnotationEffect(const ParmVarDecl *pd,
-unsigned parm_idx,
-const FunctionDecl *FD,
-RetainSummaryTemplate &Template);
+  bool applyParamAnnotationEffect(const ParmVarDecl *pd, unsigned parm_idx,
+  const NamedDecl *FD,
+  RetainSummaryTemplate &Template);
 
 public:
   RetainSummaryManager(ASTContext &ctx,

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp?rev=350865&r1=350864&r2=350865&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp Thu Jan 10 
10:15:30 2019
@@ -811,8 +811,8 @@ RetainSummaryManager::getRetEffectFromAn
   return None;
 }
 
-bool RetainSummaryManager::applyFunctionParamAnnotationEffect(
-const ParmVarDecl *pd, unsigned parm_idx, const FunctionDecl *FD,
+bool RetainSummaryManager::applyParamAnnotationEffect(
+const ParmVarDecl *pd, unsigned parm_idx, const NamedDecl *FD,
 RetainSummaryTemplate &Template) {
   QualType QT = pd->getType();
   if (auto K =
@@ -832,7 +832,7 @@ bool RetainSummaryManager::applyFunction
 if (const auto *MD = dyn_cast(FD)) {
   for (const auto *OD : MD->overridden_methods()) {
 const ParmVarDecl *OP = OD->parameters()[parm_idx];
-if (applyFunctionParamAnnotationEffect(OP, parm_idx, OD, Template))
+if (applyParamAnnotationEffect(OP, parm_idx, OD, Template))
   return true;
   }
 }
@@ -853,10 +853,8 @@ RetainSummaryManager::updateSummaryFromA
   // Effects on the parameters.
   unsigned parm_idx = 0;
   for (auto pi = FD->param_begin(),
- pe = FD->param_end(); pi != pe; ++pi, ++parm_idx) {
-const ParmVarDecl *pd = *pi;
-applyFunctionParamAnnotationEffect(pd, parm_idx, FD, Template);
-  }
+ pe = FD->param_end(); pi != pe; ++pi, ++parm_idx)
+applyParamAnnotationEffect(*pi, parm_idx, FD, Template);
 
   QualType RetTy = FD->getReturnType();
   if (Optional RetE = getRetEffectFromAnnotations(RetTy, FD))
@@ -882,19 +880,9 @@ RetainSummaryManager::updateSummaryFromA
   // Effects on the parameters.
   unsigned parm_idx = 0;
   for (auto pi = MD->param_begin(), pe = MD->param_end(); pi != pe;
-   ++pi, ++parm_idx) {
-const ParmVarDecl *pd = *pi;
-QualType QT = pd->getType();
-if (auto K =
-hasAnyEnabledAttrOf(
-pd, QT)) {
-  Template->addArg(AF, parm_idx, ArgEffect(DecRef, *K));
-} else if (auto K = hasAnyEnabledAttrOf(pd, QT)) {
-  Template->addArg(AF, parm_idx, ArgEffect(RetainedOutParameter, *K));
-} else if (auto K = hasAnyEnabledAttrOf(pd, QT)) 
{
-  Template->addArg(AF, parm_idx, ArgEffect(UnretainedOutParameter, *K));
-}
-  }
+   ++pi, ++parm_idx)
+applyParamAnnotationEffect(*pi, parm_idx, MD, Template);
+
   QualType RetTy = MD->getReturnType();
   if (Optional RetE = getRetEffectFromAnnotations(RetTy, MD))
 Template->setRetEffect(*RetE);


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


r350864 - [analyzer] [RetainCountChecker] [NFC] Remove SummaryLog

2019-01-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jan 10 10:15:17 2019
New Revision: 350864

URL: http://llvm.org/viewvc/llvm-project?rev=350864&view=rev
Log:
[analyzer] [RetainCountChecker] [NFC] Remove SummaryLog

The complicated machinery for passing the summary log around is actually
only used for one thing! To figure out whether the "dealloc" message was
sent.

Since I have tried to extend it for other uses and failed (it's actually
very hard to use), I think it's much better to simply use a tag and
remove the summary log altogether.

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

Modified:

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

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

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

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

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=350864&r1=350863&r2=350864&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
Thu Jan 10 10:15:17 2019
@@ -414,42 +414,6 @@ void RetainCountChecker::checkPostCall(c
   checkSummary(*Summ, Call, C);
 }
 
-void RetainCountChecker::checkEndAnalysis(ExplodedGraph &G, BugReporter &BR,
-  ExprEngine &Eng) const {
-  // FIXME: This is a hack to make sure the summary log gets cleared between
-  // analyses of different code bodies.
-  //
-  // Why is this necessary? Because a checker's lifetime is tied to a
-  // translation unit, but an ExplodedGraph's lifetime is just a code body.
-  // Once in a blue moon, a new ExplodedNode will have the same address as an
-  // old one with an associated summary, and the bug report visitor gets very
-  // confused. (To make things worse, the summary lifetime is currently also
-  // tied to a code body, so we get a crash instead of incorrect results.)
-  //
-  // Why is this a bad solution? Because if the lifetime of the ExplodedGraph
-  // changes, things will start going wrong again. Really the lifetime of this
-  // log needs to be tied to either the specific nodes in it or the entire
-  // ExplodedGraph, not to a specific part of the code being analyzed.
-  //
-  // (Also, having stateful local data means that the same checker can't be
-  // used from multiple threads, but a lot of checkers have incorrect
-  // assumptions about that anyway. So that wasn't a priority at the time of
-  // this fix.)
-  //
-  // This happens at the end of analysis, but bug reports are emitted /after/
-  // this point. So we can't just clear the summary log now. Instead, we mark
-  // that the next time we access the summary log, it should be cleared.
-
-  // If we never reset the summary log during /this/ code body analysis,
-  // there were no new summaries. There might still have been summaries from
-  // the /last/ analysis, so clear them out to make sure the bug report
-  // visitors don't get confused.
-  if (ShouldResetSummaryLog)
-SummaryLog.clear();
-
-  ShouldResetSummaryLog = !SummaryLog.empty();
-}
-
 CFRefBug *
 RetainCountChecker::getLeakWithinFunctionBug(const LangOptions &LOpts) const {
   if (!leakWithinFunction)
@@ -609,6 +573,11 @@ void RetainCountChecker::checkSummary(co
   SourceRange ErrorRange;
   SymbolRef ErrorSym = nullptr;
 
+  // Helper tag for providing diagnostics: indicate whether dealloc was sent
+  // at this location.
+  static CheckerProgramPointTag DeallocSentTag(this, DeallocTagDescription);
+  bool DeallocSent = false;
+
   for (unsigned idx = 0, e = CallOrMsg.getNumArgs(); idx != e; ++idx) {
 SVal V = CallOrMsg.getArgSVal(idx);
 
@@ -627,6 +596,8 @@ void RetainCountChecker::checkSummary(co
   ErrorRange = CallOrMsg.getArgSourceRange(idx);
   ErrorSym = Sym;
   break;
+} else if (Effect.getKind() == Dealloc) {
+  DeallocSent = true;
 }
   }
 }
@@ -644,6 +615,8 @@ void RetainCountChecker::checkSummary(co
   if (hasErr) {
 ErrorRange = MsgInvocation->getOriginExpr()->getReceiverRange();
 ErrorSym = Sym;
+  } else if (Summ.getReceiverEffect().getKind() == Dealloc) {
+DeallocSent = true;
   }
 }
   }
@@ -688,24 +661,10 @@ void RetainCountChecker::checkSummary(co
   state = setRefBinding(state, Sym, *updatedRefVal);
   }
 
-  // This check is actually necessary; otherwise the statement builder thinks
-  // we've hit a previously-found path.
-  // Normally addTransition takes care of this, but we want the node pointer.
-  ExplodedN

r350866 - [analyzer] [NFC] Reverse the argument order for "diff" in tests

2019-01-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jan 10 10:15:44 2019
New Revision: 350866

URL: http://llvm.org/viewvc/llvm-project?rev=350866&view=rev
Log:
[analyzer] [NFC] Reverse the argument order for "diff" in tests

The current argument order has "expected" and "actual" the wrong way around,
so that the diff shows the change from expected to actual, not from actual to 
expected.

Namely, if the expected diagnostics contains the string "foo", but the analyzer 
emits "bar",
we really want to see:

```
- foo
+ bar
```

not

```
- bar
+ foo
```

since adapting to most changes would require applying that diff to the expected 
output.

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

Modified:
cfe/trunk/test/Analysis/NewDelete-path-notes.cpp
cfe/trunk/test/Analysis/conditional-path-notes.c
cfe/trunk/test/Analysis/copypaste/plist-diagnostics-notes-as-events.cpp
cfe/trunk/test/Analysis/copypaste/plist-diagnostics.cpp
cfe/trunk/test/Analysis/cxx-for-range.cpp

cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-diagnostics-taint-test.c.sarif

cfe/trunk/test/Analysis/diagnostics/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif
cfe/trunk/test/Analysis/diagnostics/deref-track-symbolic-region.c
cfe/trunk/test/Analysis/diagnostics/report-issues-within-main-file.cpp
cfe/trunk/test/Analysis/diagnostics/sarif-diagnostics-taint-test.c
cfe/trunk/test/Analysis/diagnostics/sarif-multi-diagnostic-test.c
cfe/trunk/test/Analysis/diagnostics/undef-value-caller.c
cfe/trunk/test/Analysis/diagnostics/undef-value-param.c
cfe/trunk/test/Analysis/diagnostics/undef-value-param.m
cfe/trunk/test/Analysis/edges-new.mm
cfe/trunk/test/Analysis/generics.m
cfe/trunk/test/Analysis/inline-plist.c
cfe/trunk/test/Analysis/inline-unique-reports.c
cfe/trunk/test/Analysis/inlining/eager-reclamation-path-notes.c
cfe/trunk/test/Analysis/inlining/eager-reclamation-path-notes.cpp
cfe/trunk/test/Analysis/inlining/path-notes.c
cfe/trunk/test/Analysis/inlining/path-notes.cpp
cfe/trunk/test/Analysis/inlining/path-notes.m
cfe/trunk/test/Analysis/lit.local.cfg
cfe/trunk/test/Analysis/method-call-path-notes.cpp
cfe/trunk/test/Analysis/model-file.cpp
cfe/trunk/test/Analysis/null-deref-path-notes.m
cfe/trunk/test/Analysis/nullability-notes.m
cfe/trunk/test/Analysis/objc-arc.m
cfe/trunk/test/Analysis/plist-macros-with-expansion.cpp
cfe/trunk/test/Analysis/plist-macros.cpp
cfe/trunk/test/Analysis/plist-output-alternate.m
cfe/trunk/test/Analysis/plist-output.m
cfe/trunk/test/Analysis/retain-release-path-notes.m
cfe/trunk/test/Analysis/unix-fns.c

Modified: cfe/trunk/test/Analysis/NewDelete-path-notes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/NewDelete-path-notes.cpp?rev=350866&r1=350865&r2=350866&view=diff
==
--- cfe/trunk/test/Analysis/NewDelete-path-notes.cpp (original)
+++ cfe/trunk/test/Analysis/NewDelete-path-notes.cpp Thu Jan 10 10:15:44 2019
@@ -1,7 +1,7 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.NewDelete,unix.Malloc 
-analyzer-output=text -verify %s
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.NewDelete,unix.Malloc 
-analyzer-output=text -analyzer-config c++-allocator-inlining=true -verify %s
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.NewDelete,unix.Malloc 
-analyzer-output=plist %s -o %t.plist
-// RUN: cat %t.plist | %diff_plist 
%S/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
+// RUN: cat %t.plist | %diff_plist 
%S/Inputs/expected-plists/NewDelete-path-notes.cpp.plist -
 
 void test() {
   int *p = new int;

Modified: cfe/trunk/test/Analysis/conditional-path-notes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/conditional-path-notes.c?rev=350866&r1=350865&r2=350866&view=diff
==
--- cfe/trunk/test/Analysis/conditional-path-notes.c (original)
+++ cfe/trunk/test/Analysis/conditional-path-notes.c Thu Jan 10 10:15:44 2019
@@ -1,6 +1,6 @@
 // RUN: %clang_analyze_cc1 %s -analyzer-checker=core.NullDereference 
-analyzer-output=text -verify
 // RUN: %clang_analyze_cc1 %s -analyzer-checker=core.NullDereference 
-analyzer-output=plist -o %t
-// RUN: cat %t | %diff_plist 
%S/Inputs/expected-plists/conditional-path-notes.c.plist
+// RUN: cat %t | %diff_plist 
%S/Inputs/expected-plists/conditional-path-notes.c.plist -
 
 void testCondOp(int *p) {
   int *x = p ? p : p;

Modified: 
cfe/trunk/test/Analysis/copypaste/plist-diagnostics-notes-as-events.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/copypaste/plist-diagnostics-notes-as-events.cpp?rev=350866&r1=350865&r2=350866&view=diff
==
--- cfe/trunk/test/Analysis/copypaste/plist-diagnostics-notes-as-events.cpp 
(original)

r350868 - [analyzer] [NFC] [RetainCountChecker] Remove dead unused map

2019-01-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jan 10 10:16:10 2019
New Revision: 350868

URL: http://llvm.org/viewvc/llvm-project?rev=350868&view=rev
Log:
[analyzer] [NFC] [RetainCountChecker] Remove dead unused map

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

Modified:

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

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h?rev=350868&r1=350867&r2=350868&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h 
Thu Jan 10 10:16:10 2019
@@ -256,11 +256,6 @@ class RetainCountChecker
   mutable std::unique_ptr overAutorelease, returnNotOwnedForOwned;
   mutable std::unique_ptr leakWithinFunction, leakAtReturn;
 
-  typedef llvm::DenseMap 
SymbolTagMap;
-
-  // This map is only used to ensure proper deletion of any allocated tags.
-  mutable SymbolTagMap DeadSymbolTags;
-
   mutable std::unique_ptr Summaries;
 public:
   static constexpr const char *DeallocTagDescription = "DeallocSent";
@@ -273,7 +268,6 @@ public:
 
   RetainCountChecker() {}
 
-  ~RetainCountChecker() override { DeleteContainerSeconds(DeadSymbolTags); }
 
   CFRefBug *getLeakWithinFunctionBug(const LangOptions &LOpts) const;
 


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


r350869 - [analyzer] Update the category name for RetainCountChecker reports

2019-01-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jan 10 10:16:25 2019
New Revision: 350869

URL: http://llvm.org/viewvc/llvm-project?rev=350869&view=rev
Log:
[analyzer] Update the category name for RetainCountChecker reports

..now that it includes OSObjects

rdar://46509986

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

Modified:

cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp

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

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

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

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
cfe/trunk/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
cfe/trunk/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
cfe/trunk/test/Analysis/Inputs/expected-plists/objc-arc.m.plist
cfe/trunk/test/Analysis/Inputs/expected-plists/objc-radar17039661.m.plist

cfe/trunk/test/Analysis/Inputs/expected-plists/plist-output-alternate.m.plist
cfe/trunk/test/Analysis/Inputs/expected-plists/plist-output.m.plist

cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
cfe/trunk/test/Analysis/inlining/Inputs/expected-plists/path-notes.m.plist

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h?rev=350869&r1=350868&r2=350869&view=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h 
Thu Jan 10 10:16:25 2019
@@ -16,7 +16,7 @@ namespace clang {
 namespace categories {
   extern const char * const CoreFoundationObjectiveC;
   extern const char * const LogicError;
-  extern const char * const MemoryCoreFoundationObjectiveC;
+  extern const char * const MemoryRefCount;
   extern const char * const MemoryError;
   extern const char * const UnixAPI;
 }

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=350869&r1=350868&r2=350869&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Thu Jan 10 
10:16:25 2019
@@ -757,15 +757,15 @@ ObjCDeallocChecker::ObjCDeallocChecker()
 
   MissingReleaseBugType.reset(
   new BugType(this, "Missing ivar release (leak)",
-  categories::MemoryCoreFoundationObjectiveC));
+  categories::MemoryRefCount));
 
   ExtraReleaseBugType.reset(
   new BugType(this, "Extra ivar release",
-  categories::MemoryCoreFoundationObjectiveC));
+  categories::MemoryRefCount));
 
   MistakenDeallocBugType.reset(
   new BugType(this, "Mistaken dealloc",
-  categories::MemoryCoreFoundationObjectiveC));
+  categories::MemoryRefCount));
 }
 
 void ObjCDeallocChecker::initIdentifierInfoAndSelectors(

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=350869&r1=350868&r2=350869&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
Thu Jan 10 10:16:25 2019
@@ -39,19 +39,19 @@ ProgramStateRef removeRefBinding(Program
   return State->remove(Sym);
 }
 
-class UseAfterRelease : public CFRefBug {
+class UseAfterRelease : public RefCountBug {
 public:
   UseAfterRelease(const CheckerBase *checker)
-  : CFRefBug(checker, "Use-after-release") {}
+  : RefCountBug(checker, "Use-after-release") {}
 
   const char *getDescription() const override {
 return "Reference-counted object is used after it is released";
   }
 };
 
-class BadRelease : public CFRefBug {
+class BadRelease : public RefCountBug {
 public:
-  BadRelease(const CheckerBase *checker) : CFRefBug(checker, "Bad release") {}
+  BadRelease(const CheckerBase *checker) : RefCountBug(checker, "Bad release") 
{}
 
   const char *getDescription() const override {
 return "Incorrect decrement of the reference count of an object that is "
@@ -59,30 +59,30 @@ public:
   }
 };
 
-class DeallocNotOwned : public CFRefBug {
+class DeallocNot

[PATCH] D56402: [analyzer] [NFC] [RetainCountChecker] Remove dead unused map

2019-01-10 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350868: [analyzer] [NFC] [RetainCountChecker] Remove dead 
unused map (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56402?vs=180534&id=181098#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D56402

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h


Index: lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
@@ -256,11 +256,6 @@
   mutable std::unique_ptr overAutorelease, returnNotOwnedForOwned;
   mutable std::unique_ptr leakWithinFunction, leakAtReturn;
 
-  typedef llvm::DenseMap 
SymbolTagMap;
-
-  // This map is only used to ensure proper deletion of any allocated tags.
-  mutable SymbolTagMap DeadSymbolTags;
-
   mutable std::unique_ptr Summaries;
 public:
   static constexpr const char *DeallocTagDescription = "DeallocSent";
@@ -273,7 +268,6 @@
 
   RetainCountChecker() {}
 
-  ~RetainCountChecker() override { DeleteContainerSeconds(DeadSymbolTags); }
 
   CFRefBug *getLeakWithinFunctionBug(const LangOptions &LOpts) const;
 


Index: lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
@@ -256,11 +256,6 @@
   mutable std::unique_ptr overAutorelease, returnNotOwnedForOwned;
   mutable std::unique_ptr leakWithinFunction, leakAtReturn;
 
-  typedef llvm::DenseMap SymbolTagMap;
-
-  // This map is only used to ensure proper deletion of any allocated tags.
-  mutable SymbolTagMap DeadSymbolTags;
-
   mutable std::unique_ptr Summaries;
 public:
   static constexpr const char *DeallocTagDescription = "DeallocSent";
@@ -273,7 +268,6 @@
 
   RetainCountChecker() {}
 
-  ~RetainCountChecker() override { DeleteContainerSeconds(DeadSymbolTags); }
 
   CFRefBug *getLeakWithinFunctionBug(const LangOptions &LOpts) const;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55646: [ASTImporter] Make ODR diagnostics warning by default

2019-01-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In general, I agree that it doesn't make sense for ODR violations (with false 
positives) to trigger error diagnostics while performing AST merging, so 
downgrading this to warnings is a good idea. However, I do worry about 
impacting modules and C compatibility with the changes. I'm curious what 
@rsmith thinks the answer should be here. AFAIK, modules do not *require* ODR 
violations checks (I believe that's still ill-formed, no diagnostic required), 
but confirmation would be good.




Comment at: lib/Sema/SemaType.cpp:7609
+  StructuralEquivalenceKind::Default, false /*StrictTypeSpelling*/,
+  true /*Complain*/);
   return Ctx.IsEquivalent(D, Suggested);

Are we sure this isn't breaking C compatibility? IIRC, C has structural 
equivalence rules because it doesn't have quite the same notion of an ODR as 
C++ does regarding things like tag redeclarations. I worry that we'll be 
downgrading valid errors into warnings here because of that.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55646



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


[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56318#1352962 , @rjmccall wrote:

> If I was only concerned about `size_t`, your current solution would be fine.  
> My concern is that you really need to match *all* of the associated CPU 
> target's ABI choices, so your target really ought to be forwarding everything 
> to that target by default and only selectively overriding it in order to 
> support GPU-specific features.   Probably the easiest way to do that is via 
> inheritance.


We only need to match the type size and alignment in device and host 
compilation, but do not need to match function call ABI. In fact our backend 
has its own function ABI which is different from host on linux, but it does not 
preventing us from supporting HIP on linux. This is because the device kernel 
is launched through HIP runtime, which gets kernel argument size and offset 
from kernel image, and lays out the arguments for the kernel.

The latest CUDA kernel launching API cuLaunchKernel 
(https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EXEC.html#group__CUDA__EXEC_1gb8f3dc3031b40da29d5f9a7139e52e15)
 . Basically the host code only needs to pass an array of pointer to the 
arguments, whereas "the number of kernel parameters and their offsets and sizes 
do not need to be specified as that information is retrieved directly from the 
kernel's image".

If the device backend has to switch to different ABI according to host 
environment, that will be very painful for the backend.


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

https://reviews.llvm.org/D56318



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


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with one minor testing request (conditional on the test passing, of 
course).




Comment at: unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp:68
 }
 
 TEST(RecursiveASTVisitor, VisitsAttributedLambdaExpr) {

Can you add a test that has a lambda within a lambda to ensure that everything 
is traversed as expected?


Repository:
  rC Clang

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

https://reviews.llvm.org/D56444



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


r350870 - [analyzer] [hotfix] Fix the tests

2019-01-10 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jan 10 10:28:10 2019
New Revision: 350870

URL: http://llvm.org/viewvc/llvm-project?rev=350870&view=rev
Log:
[analyzer] [hotfix] Fix the tests

The error must have crept during the cherry-pick.

Modified:

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

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp?rev=350870&r1=350869&r2=350870&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
 (original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
 Thu Jan 10 10:28:10 2019
@@ -156,23 +156,25 @@ static void generateDiagnosticsForCallLi
 }
   }
 
+   os << " returns ";
+
   if (CurrV.getObjKind() == ObjKind::CF) {
-os << " a Core Foundation object of type '"
+os << "a Core Foundation object of type '"
<< Sym->getType().getAsString() << "' with a ";
   } else if (CurrV.getObjKind() == ObjKind::OS) {
-os << " an OSObject of type '" << getPrettyTypeName(Sym->getType())
+os << "an OSObject of type '" << getPrettyTypeName(Sym->getType())
<< "' with a ";
   } else if (CurrV.getObjKind() == ObjKind::Generalized) {
-os << " an object of type '" << Sym->getType().getAsString()
+os << "an object of type '" << Sym->getType().getAsString()
<< "' with a ";
   } else {
 assert(CurrV.getObjKind() == ObjKind::ObjC);
 QualType T = Sym->getType();
 if (!isa(T)) {
-  os << " returns an Objective-C object with a ";
+  os << "an Objective-C object with a ";
 } else {
   const ObjCObjectPointerType *PT = cast(T);
-  os << " returns an instance of " << PT->getPointeeType().getAsString()
+  os << "an instance of " << PT->getPointeeType().getAsString()
  << " with a ";
 }
   }


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


[PATCH] D56225: [HIP] Use nul instead of /dev/null when running on windows

2019-01-10 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Driver/ToolChains/HIP.cpp:210
   std::string BundlerTargetArg = "-targets=host-x86_64-unknown-linux";
-  std::string BundlerInputArg = "-inputs=/dev/null";
+  std::string BundlerInputArg = "-inputs=" NULL_FILE;
 

yaxunl wrote:
> rjmccall wrote:
> > How hard would it be to just implement the TODO and get away from a 
> > reliance on a null file?
> I tried to make clang-offloader-bundler work without host target but it is 
> not easy. Since it is shared with other languages e.g. OpenMP, it has a 
> fundamental assumption that there is one host target. To make it work without 
> host target may result in format changes that affecting HIP runtime, which is 
> something I would like to avoid for now.
Okay, if this is the only reasonable way you can find to do it, it's fine.


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

https://reviews.llvm.org/D56225



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


[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

No, I understand that things like the function-call ABI should be different 
from the associated host ABI, but things like the size of `long` and the 
bit-field layout algorithm presumably shouldn't be, and that's the sort of 
thing that's configured by `TargetInfo`.


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

https://reviews.llvm.org/D56318



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


[PATCH] D56552: [clang-tidy] update FunctionSizeCheck for D56444

2019-01-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56552



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


[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56318#1353106 , @rjmccall wrote:

> No, I understand that things like the function-call ABI should be different 
> from the associated host ABI, but things like the size of `long` and the 
> bit-field layout algorithm presumably shouldn't be, and that's the sort of 
> thing that's configured by `TargetInfo`.


How about create a ForwardingTargegInfo which will has a pointer to AuxTarget 
and forward to that target if it is not null. Then let AMDGPUTargetInfo inherit 
from that.


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

https://reviews.llvm.org/D56318



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


[PATCH] D41941: [WebAssembly] Change int_fast16_t to 32-bit

2019-01-10 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added a comment.

As @nw points out, clang's lib/Headers/stdint.h doesn't support this yet. 
Unless anyone feels strongly, I now propose we close this and just leave 
int_fast16_t/uint_fast16_t as-is.


Repository:
  rC Clang

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

https://reviews.llvm.org/D41941



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


[PATCH] D53541: [COFF, ARM64] Do not emit x86_seh_recoverfp intrinsic

2019-01-10 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 181106.
mgrang retitled this revision from "[COFF, ARM64] Support SEH for ARM64 
Windows" to "[COFF, ARM64] Do not emit x86_seh_recoverfp intrinsic".

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

https://reviews.llvm.org/D53541

Files:
  lib/CodeGen/CGException.cpp
  test/CodeGen/exceptions-seh.c


Index: test/CodeGen/exceptions-seh.c
===
--- test/CodeGen/exceptions-seh.c
+++ test/CodeGen/exceptions-seh.c
@@ -2,8 +2,6 @@
 // RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=X64
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - \
 // RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=X86
-// RUN: %clang_cc1 %s -triple aarch64-windows -fms-extensions -emit-llvm -o - \
-// RUN: | FileCheck %s --check-prefixes=CHECK,ARM64
 // RUN: %clang_cc1 %s -triple i686-pc-windows-gnu -fms-extensions -emit-llvm 
-o - \
 // RUN: | FileCheck %s --check-prefix=X86-GNU
 // RUN: %clang_cc1 %s -triple x86_64-pc-windows-gnu -fms-extensions -emit-llvm 
-o - \
@@ -31,14 +29,12 @@
 
 // CHECK-LABEL: define dso_local i32 @safe_div(i32 %numerator, i32 
%denominator, i32* %res)
 // X64-SAME:  personality i8* bitcast (i32 (...)* @__C_specific_handler to 
i8*)
-// ARM64-SAME:personality i8* bitcast (i32 (...)* @__C_specific_handler to 
i8*)
 // X86-SAME:  personality i8* bitcast (i32 (...)* @_except_handler3 to i8*)
 // CHECK: invoke void @try_body(i32 %{{.*}}, i32 %{{.*}}, i32* %{{.*}}) 
#[[NOINLINE:[0-9]+]]
 // CHECK:   to label %{{.*}} unwind label %[[catchpad:[^ ]*]]
 //
 // CHECK: [[catchpad]]
 // X64: %[[padtoken:[^ ]*]] = catchpad within %{{[^ ]*}} [i8* null]
-// ARM64: %[[padtoken:[^ ]*]] = catchpad within %{{[^ ]*}} [i8* null]
 // X86: %[[padtoken:[^ ]*]] = catchpad within %{{[^ ]*}} [i8* bitcast (i32 ()* 
@"?filt$0@0@safe_div@@" to i8*)]
 // CHECK-NEXT: catchret from %[[padtoken]] to label %[[except:[^ ]*]]
 //
@@ -80,10 +76,8 @@
 
 // CHECK-LABEL: define dso_local i32 @filter_expr_capture()
 // X64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
-// ARM64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to 
i8*)
 // X86-SAME: personality i8* bitcast (i32 (...)* @_except_handler3 to i8*)
 // X64: call void (...) @llvm.localescape(i32* %[[r:[^ ,]*]])
-// ARM64: call void (...) @llvm.localescape(i32* %[[r:[^ ,]*]])
 // X86: call void (...) @llvm.localescape(i32* %[[r:[^ ,]*]], i32* %[[code:[^ 
,]*]])
 // CHECK: store i32 42, i32* %[[r]]
 // CHECK: invoke void @j() #[[NOINLINE]]
@@ -98,10 +92,6 @@
 // X64: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* 
@filter_expr_capture to i8*), i8* %frame_pointer)
 // X64: call i8* @llvm.localrecover(i8* bitcast (i32 ()* @filter_expr_capture 
to i8*), i8* %[[fp]], i32 0)
 //
-// ARM64-LABEL: define internal i32 @"?filt$0@0@filter_expr_capture@@"(i8* 
%exception_pointers, i8* %frame_pointer)
-// ARM64: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 
()* @filter_expr_capture to i8*), i8* %frame_pointer)
-// ARM64: call i8* @llvm.localrecover(i8* bitcast (i32 ()* 
@filter_expr_capture to i8*), i8* %[[fp]], i32 0)
-//
 // X86-LABEL: define internal i32 @"?filt$0@0@filter_expr_capture@@"()
 // X86: %[[ebp:[^ ]*]] = call i8* @llvm.frameaddress(i32 1)
 // X86: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* 
@filter_expr_capture to i8*), i8* %[[ebp]])
@@ -126,7 +116,6 @@
 }
 // CHECK-LABEL: define dso_local i32 @nested_try()
 // X64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
-// ARM64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to 
i8*)
 // X86-SAME: personality i8* bitcast (i32 (...)* @_except_handler3 to i8*)
 // CHECK: store i32 42, i32* %[[r:[^ ,]*]]
 // CHECK: invoke void @j() #[[NOINLINE]]
@@ -187,7 +176,6 @@
 }
 // CHECK-LABEL: define dso_local i32 @basic_finally(i32 %g)
 // X64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
-// ARM64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to 
i8*)
 // X86-SAME: personality i8* bitcast (i32 (...)* @_except_handler3 to i8*)
 // CHECK: %[[g_addr:[^ ]*]] = alloca i32, align 4
 // CHECK: call void (...) @llvm.localescape(i32* %[[g_addr]])
@@ -287,8 +275,6 @@
 // CHECK: catchret from %[[pad]]
 // X64: %[[code:[^ ]*]] = call i32 @llvm.eh.exceptioncode(token %[[pad]])
 // X64: store i32 %[[code]], i32* %[[code_slot]]
-// ARM64: %[[code:[^ ]*]] = call i32 @llvm.eh.exceptioncode(token %[[pad]])
-// ARM64: store i32 %[[code]], i32* %[[code_slot]]
 // CHECK: %[[ret1:[^ ]*]] = load i32, i32* %[[code_slot]]
 // CHECK: store i32 %[[ret1]], i32* %[[ret_slot]]
 // CHECK: %[[ret2:[^ ]*]] = load i32, i32* %[[ret_slot]]
Index: lib/CodeGen/CGException.cpp
===
--- lib/CodeGen/CGException.cpp
+++ lib/CodeGen/CGExcep

r350874 - Fix false positive unsequenced access and modification warning in array subscript expression.

2019-01-10 Thread Nicolas Lesser via cfe-commits
Author: rakete
Date: Thu Jan 10 11:03:33 2019
New Revision: 350874

URL: http://llvm.org/viewvc/llvm-project?rev=350874&view=rev
Log:
Fix false positive unsequenced access and modification warning in array 
subscript expression.

Summary: In the [expr.sub] p1, we can read that for a given E1[E2], E1 is 
sequenced before E2. 

Patch by Mateusz Janek.

Reviewers: rsmith, Rakete

Reviewed By: rsmith, Rakete

Subscribers: riccibruno, lebedev.ri, Rakete, hiraditya, cfe-commits

Tags: #clang

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


Added:
cfe/trunk/test/SemaCXX/warn-unsequenced-cxx17.cpp
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/warn-unsequenced.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=350874&r1=350873&r2=350874&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Jan 10 11:03:33 2019
@@ -11908,30 +11908,42 @@ public:
   notePostUse(O, E);
   }
 
-  void VisitBinComma(BinaryOperator *BO) {
-// C++11 [expr.comma]p1:
-//   Every value computation and side effect associated with the left
-//   expression is sequenced before every value computation and side
-//   effect associated with the right expression.
-SequenceTree::Seq LHS = Tree.allocate(Region);
-SequenceTree::Seq RHS = Tree.allocate(Region);
+  void VisitSequencedExpressions(Expr *SequencedBefore, Expr *SequencedAfter) {
+SequenceTree::Seq BeforeRegion = Tree.allocate(Region);
+SequenceTree::Seq AfterRegion = Tree.allocate(Region);
 SequenceTree::Seq OldRegion = Region;
 
 {
-  SequencedSubexpression SeqLHS(*this);
-  Region = LHS;
-  Visit(BO->getLHS());
+  SequencedSubexpression SeqBefore(*this);
+  Region = BeforeRegion;
+  Visit(SequencedBefore);
 }
 
-Region = RHS;
-Visit(BO->getRHS());
+Region = AfterRegion;
+Visit(SequencedAfter);
 
 Region = OldRegion;
 
-// Forget that LHS and RHS are sequenced. They are both unsequenced
-// with respect to other stuff.
-Tree.merge(LHS);
-Tree.merge(RHS);
+Tree.merge(BeforeRegion);
+Tree.merge(AfterRegion);
+  }
+
+  void VisitArraySubscriptExpr(ArraySubscriptExpr *ASE) {
+// C++17 [expr.sub]p1:
+//   The expression E1[E2] is identical (by definition) to *((E1)+(E2)). 
The
+//   expression E1 is sequenced before the expression E2.
+if (SemaRef.getLangOpts().CPlusPlus17)
+  VisitSequencedExpressions(ASE->getLHS(), ASE->getRHS());
+else
+  Base::VisitStmt(ASE);
+  }
+
+  void VisitBinComma(BinaryOperator *BO) {
+// C++11 [expr.comma]p1:
+//   Every value computation and side effect associated with the left
+//   expression is sequenced before every value computation and side
+//   effect associated with the right expression.
+VisitSequencedExpressions(BO->getLHS(), BO->getRHS());
   }
 
   void VisitBinAssign(BinaryOperator *BO) {

Added: cfe/trunk/test/SemaCXX/warn-unsequenced-cxx17.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unsequenced-cxx17.cpp?rev=350874&view=auto
==
--- cfe/trunk/test/SemaCXX/warn-unsequenced-cxx17.cpp (added)
+++ cfe/trunk/test/SemaCXX/warn-unsequenced-cxx17.cpp Thu Jan 10 11:03:33 2019
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wno-unused %s
+
+void test() {
+  int xs[10];
+  int *p = xs;
+  // expected-no-diagnostics
+  p[(long long unsigned)(p = 0)]; // ok
+}

Modified: cfe/trunk/test/SemaCXX/warn-unsequenced.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unsequenced.cpp?rev=350874&r1=350873&r2=350874&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-unsequenced.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unsequenced.cpp Thu Jan 10 11:03:33 2019
@@ -81,6 +81,7 @@ void test() {
   int *p = xs;
   a = *(a++, p); // ok
   a = a++ && a; // ok
+  p[(long long unsigned)(p = 0)]; // expected-warning {{unsequenced 
modification and access to 'p'}}
 
   A *q = &agg1;
   (q = &agg2)->y = q->x; // expected-warning {{unsequenced modification and 
access to 'q'}}


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


[PATCH] D56523: Improve a -Wunguarded-availability note

2019-01-10 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/test/Sema/availability-guard-format.mm:6
 @interface foo
-- (void) method_bar __attribute__((availability(macosx, introduced = 10_12))); 
// expected-note {{'method_bar' has been explicitly marked partial here}}
+- (void) method_bar __attribute__((availability(macosx, introduced = 10_12))); 
// expected-note {{'method_bar' has been marked as being introduced in macOS 
10.12 here, but the deployment target is macOS 10.4.0}}
 @end

erik.pilkington wrote:
> jkorous wrote:
> > I am probably missing something but where is the deployment target value 
> > set?
> Its set implicitly, but you can also control it with `-mmacos-version-min=` 
> flag.
Would it be better to set the deployment target explicitly in this test?  
Otherwise we're implicitly testing what the default is, which seems orthogonal 
to what the diagnostic should say.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56523



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


[PATCH] D56522: [SemaCXX] add -Woverride-init alias to -Winitializer-overrides

2019-01-10 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 181108.
nickdesaulniers added a comment.

- add gcc compat comment


Repository:
  rC Clang

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

https://reviews.llvm.org/D56522

Files:
  docs/DiagnosticsReference.rst
  include/clang/Basic/DiagnosticGroups.td
  test/SemaCXX/designated-initializers.cpp


Index: test/SemaCXX/designated-initializers.cpp
===
--- test/SemaCXX/designated-initializers.cpp
+++ test/SemaCXX/designated-initializers.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Woverride-init %s
 
 template  struct Foo {
   struct SubFoo {
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -361,6 +361,8 @@
 def NullCharacter : DiagGroup<"null-character">;
 def NullDereference : DiagGroup<"null-dereference">;
 def InitializerOverrides : DiagGroup<"initializer-overrides">;
+// For compatibility with GCC; -Woverride-init = -Winitializer-overrides
+def : DiagGroup<"override-init", [InitializerOverrides]>;
 def NonNull : DiagGroup<"nonnull">;
 def NonPODVarargs : DiagGroup<"non-pod-varargs">;
 def ClassVarargs : DiagGroup<"class-varargs", [NonPODVarargs]>;
Index: docs/DiagnosticsReference.rst
===
--- docs/DiagnosticsReference.rst
+++ docs/DiagnosticsReference.rst
@@ -7885,6 +7885,10 @@
 |  
 |+-+|
 
+---+---+
 
+-Woverride-init
+--
+Synonym for `-Winitializer-overrides`_.
+
 
 -Woverride-module
 -


Index: test/SemaCXX/designated-initializers.cpp
===
--- test/SemaCXX/designated-initializers.cpp
+++ test/SemaCXX/designated-initializers.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Woverride-init %s
 
 template  struct Foo {
   struct SubFoo {
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -361,6 +361,8 @@
 def NullCharacter : DiagGroup<"null-character">;
 def NullDereference : DiagGroup<"null-dereference">;
 def InitializerOverrides : DiagGroup<"initializer-overrides">;
+// For compatibility with GCC; -Woverride-init = -Winitializer-overrides
+def : DiagGroup<"override-init", [InitializerOverrides]>;
 def NonNull : DiagGroup<"nonnull">;
 def NonPODVarargs : DiagGroup<"non-pod-varargs">;
 def ClassVarargs : DiagGroup<"class-varargs", [NonPODVarargs]>;
Index: docs/DiagnosticsReference.rst
===
--- docs/DiagnosticsReference.rst
+++ docs/DiagnosticsReference.rst
@@ -7885,6 +7885,10 @@
 |   |+-+|
 +---+---+
 
+-Woverride-init
+--
+Synonym for `-Winitializer-overrides`_.
+
 
 -Woverride-module
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50766: Fix false positive unsequenced access and modification warning in array subscript expression.

2019-01-10 Thread Nicolas Lesser via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350874: Fix false positive unsequenced access and 
modification warning in array… (authored by Rakete, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D50766

Files:
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/warn-unsequenced-cxx17.cpp
  test/SemaCXX/warn-unsequenced.cpp


Index: test/SemaCXX/warn-unsequenced.cpp
===
--- test/SemaCXX/warn-unsequenced.cpp
+++ test/SemaCXX/warn-unsequenced.cpp
@@ -81,6 +81,7 @@
   int *p = xs;
   a = *(a++, p); // ok
   a = a++ && a; // ok
+  p[(long long unsigned)(p = 0)]; // expected-warning {{unsequenced 
modification and access to 'p'}}
 
   A *q = &agg1;
   (q = &agg2)->y = q->x; // expected-warning {{unsequenced modification and 
access to 'q'}}
Index: test/SemaCXX/warn-unsequenced-cxx17.cpp
===
--- test/SemaCXX/warn-unsequenced-cxx17.cpp
+++ test/SemaCXX/warn-unsequenced-cxx17.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wno-unused %s
+
+void test() {
+  int xs[10];
+  int *p = xs;
+  // expected-no-diagnostics
+  p[(long long unsigned)(p = 0)]; // ok
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -11908,30 +11908,42 @@
   notePostUse(O, E);
   }
 
-  void VisitBinComma(BinaryOperator *BO) {
-// C++11 [expr.comma]p1:
-//   Every value computation and side effect associated with the left
-//   expression is sequenced before every value computation and side
-//   effect associated with the right expression.
-SequenceTree::Seq LHS = Tree.allocate(Region);
-SequenceTree::Seq RHS = Tree.allocate(Region);
+  void VisitSequencedExpressions(Expr *SequencedBefore, Expr *SequencedAfter) {
+SequenceTree::Seq BeforeRegion = Tree.allocate(Region);
+SequenceTree::Seq AfterRegion = Tree.allocate(Region);
 SequenceTree::Seq OldRegion = Region;
 
 {
-  SequencedSubexpression SeqLHS(*this);
-  Region = LHS;
-  Visit(BO->getLHS());
+  SequencedSubexpression SeqBefore(*this);
+  Region = BeforeRegion;
+  Visit(SequencedBefore);
 }
 
-Region = RHS;
-Visit(BO->getRHS());
+Region = AfterRegion;
+Visit(SequencedAfter);
 
 Region = OldRegion;
 
-// Forget that LHS and RHS are sequenced. They are both unsequenced
-// with respect to other stuff.
-Tree.merge(LHS);
-Tree.merge(RHS);
+Tree.merge(BeforeRegion);
+Tree.merge(AfterRegion);
+  }
+
+  void VisitArraySubscriptExpr(ArraySubscriptExpr *ASE) {
+// C++17 [expr.sub]p1:
+//   The expression E1[E2] is identical (by definition) to *((E1)+(E2)). 
The
+//   expression E1 is sequenced before the expression E2.
+if (SemaRef.getLangOpts().CPlusPlus17)
+  VisitSequencedExpressions(ASE->getLHS(), ASE->getRHS());
+else
+  Base::VisitStmt(ASE);
+  }
+
+  void VisitBinComma(BinaryOperator *BO) {
+// C++11 [expr.comma]p1:
+//   Every value computation and side effect associated with the left
+//   expression is sequenced before every value computation and side
+//   effect associated with the right expression.
+VisitSequencedExpressions(BO->getLHS(), BO->getRHS());
   }
 
   void VisitBinAssign(BinaryOperator *BO) {


Index: test/SemaCXX/warn-unsequenced.cpp
===
--- test/SemaCXX/warn-unsequenced.cpp
+++ test/SemaCXX/warn-unsequenced.cpp
@@ -81,6 +81,7 @@
   int *p = xs;
   a = *(a++, p); // ok
   a = a++ && a; // ok
+  p[(long long unsigned)(p = 0)]; // expected-warning {{unsequenced modification and access to 'p'}}
 
   A *q = &agg1;
   (q = &agg2)->y = q->x; // expected-warning {{unsequenced modification and access to 'q'}}
Index: test/SemaCXX/warn-unsequenced-cxx17.cpp
===
--- test/SemaCXX/warn-unsequenced-cxx17.cpp
+++ test/SemaCXX/warn-unsequenced-cxx17.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wno-unused %s
+
+void test() {
+  int xs[10];
+  int *p = xs;
+  // expected-no-diagnostics
+  p[(long long unsigned)(p = 0)]; // ok
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -11908,30 +11908,42 @@
   notePostUse(O, E);
   }
 
-  void VisitBinComma(BinaryOperator *BO) {
-// C++11 [expr.comma]p1:
-//   Every value computation and side effect associated with the left
-//   expression is sequenced before every value computation and side
-//   effect associated with the right expression.
-SequenceTree::Seq LHS = Tree.allocate(Region);
-SequenceTre

[PATCH] D43540: [WebAssembly] Enable -Werror=strict-prototypes by default

2019-01-10 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added a comment.

With https://reviews.llvm.org/D48471 and related work, it's not less urgent to 
do this. And since there were objections to having target-specific warnings 
anyway, let's close this.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D43540



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


r350877 - [SemaCXX] add -Woverride-init alias to -Winitializer-overrides

2019-01-10 Thread Nick Desaulniers via cfe-commits
Author: nickdesaulniers
Date: Thu Jan 10 11:12:39 2019
New Revision: 350877

URL: http://llvm.org/viewvc/llvm-project?rev=350877&view=rev
Log:
[SemaCXX] add -Woverride-init alias to -Winitializer-overrides

Summary:
https://bugs.llvm.org/show_bug.cgi?id=40251
https://github.com/ClangBuiltLinux/linux/issues/307

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits, nathanchance, srhines

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

Modified:
cfe/trunk/docs/DiagnosticsReference.rst
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/test/SemaCXX/designated-initializers.cpp

Modified: cfe/trunk/docs/DiagnosticsReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/DiagnosticsReference.rst?rev=350877&r1=350876&r2=350877&view=diff
==
--- cfe/trunk/docs/DiagnosticsReference.rst (original)
+++ cfe/trunk/docs/DiagnosticsReference.rst Thu Jan 10 11:12:39 2019
@@ -7885,6 +7885,10 @@ This diagnostic is enabled by default.
 |  
 |+-+|
 
+---+---+
 
+-Woverride-init
+--
+Synonym for `-Winitializer-overrides`_.
+
 
 -Woverride-module
 -

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=350877&r1=350876&r2=350877&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Jan 10 11:12:39 2019
@@ -365,6 +365,8 @@ def NullArithmetic : DiagGroup<"null-ari
 def NullCharacter : DiagGroup<"null-character">;
 def NullDereference : DiagGroup<"null-dereference">;
 def InitializerOverrides : DiagGroup<"initializer-overrides">;
+// For compatibility with GCC; -Woverride-init = -Winitializer-overrides
+def : DiagGroup<"override-init", [InitializerOverrides]>;
 def NonNull : DiagGroup<"nonnull">;
 def NonPODVarargs : DiagGroup<"non-pod-varargs">;
 def ClassVarargs : DiagGroup<"class-varargs", [NonPODVarargs]>;

Modified: cfe/trunk/test/SemaCXX/designated-initializers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/designated-initializers.cpp?rev=350877&r1=350876&r2=350877&view=diff
==
--- cfe/trunk/test/SemaCXX/designated-initializers.cpp (original)
+++ cfe/trunk/test/SemaCXX/designated-initializers.cpp Thu Jan 10 11:12:39 2019
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Woverride-init %s
 
 template  struct Foo {
   struct SubFoo {


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


[PATCH] D56066: [OpenCL] Address space for default class members

2019-01-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 181112.
Anastasia added a comment.

Modified conversion sequence to perform address space conversion after 
temporary materialization conversion.


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

https://reviews.llvm.org/D56066

Files:
  include/clang/Sema/Sema.h
  lib/AST/Expr.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCLCXX/addrspace-of-this.cl
  test/SemaOpenCLCXX/address-space-templates.cl

Index: test/SemaOpenCLCXX/address-space-templates.cl
===
--- test/SemaOpenCLCXX/address-space-templates.cl
+++ test/SemaOpenCLCXX/address-space-templates.cl
@@ -5,7 +5,7 @@
   T a;// expected-error{{field may not be qualified with an address space}}
   T f1(); // expected-error{{function type may not be qualified with an address space}}
   // FIXME: Should only get the error message once.
-  void f2(T); // expected-error{{parameter may not be qualified with an address space}} expected-error{{parameter may not be qualified with an address space}}
+  void f2(T); // expected-error{{parameter may not be qualified with an address space}}
 
 };
 
Index: test/CodeGenOpenCLCXX/addrspace-of-this.cl
===
--- test/CodeGenOpenCLCXX/addrspace-of-this.cl
+++ test/CodeGenOpenCLCXX/addrspace-of-this.cl
@@ -9,18 +9,21 @@
 public:
   int v;
   C() { v = 2; }
-  // FIXME: Does not work yet.
-  // C(C &&c) { v = c.v; }
+  C(C &&c) { v = c.v; }
   C(const C &c) { v = c.v; }
   C &operator=(const C &c) {
 v = c.v;
 return *this;
   }
-  // FIXME: Does not work yet.
-  //C &operator=(C&& c) & {
-  //  v = c.v;
-  //  return *this;
-  //}
+  C &operator=(C &&c) & {
+v = c.v;
+return *this;
+  }
+
+  C operator+(const C& c) {
+v += c.v;
+return *this;
+  }
 
   int get() { return v; }
 
@@ -41,15 +44,13 @@
   C c1(c);
   C c2;
   c2 = c1;
-  // FIXME: Does not work yet.
-  // C c3 = c1 + c2;
-  // C c4(foo());
-  // C c5 = foo();
-
+  C c3 = c1 + c2;
+  C c4(foo());
+  C c5 = foo();
 }
 
 // CHECK-LABEL: @__cxx_global_var_init()
-// CHECK: call void @_ZNU3AS41CC1Ev(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) #4
+// CHECK: call void @_ZNU3AS41CC1Ev(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*))
 
 // Test that the address space is __generic for the constructor
 // CHECK-LABEL: @_ZNU3AS41CC1Ev(%class.C addrspace(4)* %this)
@@ -57,7 +58,7 @@
 // CHECK:   %this.addr = alloca %class.C addrspace(4)*, align 4
 // CHECK:   store %class.C addrspace(4)* %this, %class.C addrspace(4)** %this.addr, align 4
 // CHECK:   %this1 = load %class.C addrspace(4)*, %class.C addrspace(4)** %this.addr, align 4
-// CHECK:   call void @_ZNU3AS41CC2Ev(%class.C addrspace(4)* %this1) #4
+// CHECK:   call void @_ZNU3AS41CC2Ev(%class.C addrspace(4)* %this1)
 // CHECK:   ret void
 
 // CHECK-LABEL: @_Z12test__globalv()
@@ -74,13 +75,29 @@
 
 // Test the address space of 'this' when invoking a constructor.
 // CHECK:   %1 = addrspacecast %class.C* %c2 to %class.C addrspace(4)*
-// CHECK:   call void @_ZNU3AS41CC1Ev(%class.C addrspace(4)* %1) #4
+// CHECK:   call void @_ZNU3AS41CC1Ev(%class.C addrspace(4)* %1)
 
 // Test the address space of 'this' when invoking assignment operator.
 // CHECK:   %2 = addrspacecast %class.C* %c1 to %class.C addrspace(4)*
 // CHECK:   %3 = addrspacecast %class.C* %c2 to %class.C addrspace(4)*
 // CHECK:   %call2 = call dereferenceable(4) %class.C addrspace(4)* @_ZNU3AS41CaSERU3AS4KS_(%class.C addrspace(4)* %3, %class.C addrspace(4)* dereferenceable(4) %2)
 
+// Test the address space of 'this' when invoking the operator+
+// CHECK:   %4 = addrspacecast %class.C* %c1 to %class.C addrspace(4)*
+// CHECK:   %5 = addrspacecast %class.C* %c2 to %class.C addrspace(4)*
+// CHECK:   call void @_ZNU3AS41CplERU3AS4KS_(%class.C* sret %c3, %class.C addrspace(4)* %4, %class.C addrspace(4)* dereferenceable(4) %5)
+
+// Test the address space of 'this' when invoking the move constructor
+// CHECK:   %6 = addrspacecast %class.C* %c4 to %class.C addrspace(4)*
+// CHECK:   %call3 = call spir_func dereferenceable(4) %class.C addrspace(4)* @_Z3foov()
+// CHECK:   call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* %6, %class.C addrspace(4)* dereferenceable(4) %call3)
+
+// Test the address space of 'this' when invoking the move assignment
+// CHECK:   %7 = addrspacecast %class.C* %c5 to %class.C addrspace(4)*
+// CHECK:   %call4 = call spir_func dereferenceable(4) %class.C addrspace(4)* @_Z3foov() #5
+// CHECK:   call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* %7, %class.C addrspace(4)* dereferenceable(4) %call4)
+
+
 #define TEST(AS) \
   __kernel void test##AS() { \
 AS C c;  

[PATCH] D56522: [SemaCXX] add -Woverride-init alias to -Winitializer-overrides

2019-01-10 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350877: [SemaCXX] add -Woverride-init alias to 
-Winitializer-overrides (authored by nickdesaulniers, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56522

Files:
  cfe/trunk/docs/DiagnosticsReference.rst
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/test/SemaCXX/designated-initializers.cpp


Index: cfe/trunk/docs/DiagnosticsReference.rst
===
--- cfe/trunk/docs/DiagnosticsReference.rst
+++ cfe/trunk/docs/DiagnosticsReference.rst
@@ -7885,6 +7885,10 @@
 |  
 |+-+|
 
+---+---+
 
+-Woverride-init
+--
+Synonym for `-Winitializer-overrides`_.
+
 
 -Woverride-module
 -
Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -365,6 +365,8 @@
 def NullCharacter : DiagGroup<"null-character">;
 def NullDereference : DiagGroup<"null-dereference">;
 def InitializerOverrides : DiagGroup<"initializer-overrides">;
+// For compatibility with GCC; -Woverride-init = -Winitializer-overrides
+def : DiagGroup<"override-init", [InitializerOverrides]>;
 def NonNull : DiagGroup<"nonnull">;
 def NonPODVarargs : DiagGroup<"non-pod-varargs">;
 def ClassVarargs : DiagGroup<"class-varargs", [NonPODVarargs]>;
Index: cfe/trunk/test/SemaCXX/designated-initializers.cpp
===
--- cfe/trunk/test/SemaCXX/designated-initializers.cpp
+++ cfe/trunk/test/SemaCXX/designated-initializers.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Woverride-init %s
 
 template  struct Foo {
   struct SubFoo {


Index: cfe/trunk/docs/DiagnosticsReference.rst
===
--- cfe/trunk/docs/DiagnosticsReference.rst
+++ cfe/trunk/docs/DiagnosticsReference.rst
@@ -7885,6 +7885,10 @@
 |   |+-+|
 +---+---+
 
+-Woverride-init
+--
+Synonym for `-Winitializer-overrides`_.
+
 
 -Woverride-module
 -
Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -365,6 +365,8 @@
 def NullCharacter : DiagGroup<"null-character">;
 def NullDereference : DiagGroup<"null-dereference">;
 def InitializerOverrides : DiagGroup<"initializer-overrides">;
+// For compatibility with GCC; -Woverride-init = -Winitializer-overrides
+def : DiagGroup<"override-init", [InitializerOverrides]>;
 def NonNull : DiagGroup<"nonnull">;
 def NonPODVarargs : DiagGroup<"non-pod-varargs">;
 def ClassVarargs : DiagGroup<"class-varargs", [NonPODVarargs]>;
Index: cfe/trunk/test/SemaCXX/designated-initializers.cpp
===
--- cfe/trunk/test/SemaCXX/designated-initializers.cpp
+++ cfe/trunk/test/SemaCXX/designated-initializers.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Woverride-init %s
 
 template  struct Foo {
   struct SubFoo {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56066: [OpenCL] Address space for default class members

2019-01-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 181114.
Anastasia added a comment.

Removed FIXME that this patch fixes.


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

https://reviews.llvm.org/D56066

Files:
  include/clang/Sema/Sema.h
  lib/AST/Expr.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCLCXX/addrspace-of-this.cl
  test/SemaOpenCLCXX/address-space-templates.cl

Index: test/SemaOpenCLCXX/address-space-templates.cl
===
--- test/SemaOpenCLCXX/address-space-templates.cl
+++ test/SemaOpenCLCXX/address-space-templates.cl
@@ -4,9 +4,7 @@
 struct S {
   T a;// expected-error{{field may not be qualified with an address space}}
   T f1(); // expected-error{{function type may not be qualified with an address space}}
-  // FIXME: Should only get the error message once.
-  void f2(T); // expected-error{{parameter may not be qualified with an address space}} expected-error{{parameter may not be qualified with an address space}}
-
+  void f2(T); // expected-error{{parameter may not be qualified with an address space}}
 };
 
 template 
Index: test/CodeGenOpenCLCXX/addrspace-of-this.cl
===
--- test/CodeGenOpenCLCXX/addrspace-of-this.cl
+++ test/CodeGenOpenCLCXX/addrspace-of-this.cl
@@ -9,18 +9,21 @@
 public:
   int v;
   C() { v = 2; }
-  // FIXME: Does not work yet.
-  // C(C &&c) { v = c.v; }
+  C(C &&c) { v = c.v; }
   C(const C &c) { v = c.v; }
   C &operator=(const C &c) {
 v = c.v;
 return *this;
   }
-  // FIXME: Does not work yet.
-  //C &operator=(C&& c) & {
-  //  v = c.v;
-  //  return *this;
-  //}
+  C &operator=(C &&c) & {
+v = c.v;
+return *this;
+  }
+
+  C operator+(const C& c) {
+v += c.v;
+return *this;
+  }
 
   int get() { return v; }
 
@@ -41,15 +44,13 @@
   C c1(c);
   C c2;
   c2 = c1;
-  // FIXME: Does not work yet.
-  // C c3 = c1 + c2;
-  // C c4(foo());
-  // C c5 = foo();
-
+  C c3 = c1 + c2;
+  C c4(foo());
+  C c5 = foo();
 }
 
 // CHECK-LABEL: @__cxx_global_var_init()
-// CHECK: call void @_ZNU3AS41CC1Ev(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) #4
+// CHECK: call void @_ZNU3AS41CC1Ev(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*))
 
 // Test that the address space is __generic for the constructor
 // CHECK-LABEL: @_ZNU3AS41CC1Ev(%class.C addrspace(4)* %this)
@@ -57,7 +58,7 @@
 // CHECK:   %this.addr = alloca %class.C addrspace(4)*, align 4
 // CHECK:   store %class.C addrspace(4)* %this, %class.C addrspace(4)** %this.addr, align 4
 // CHECK:   %this1 = load %class.C addrspace(4)*, %class.C addrspace(4)** %this.addr, align 4
-// CHECK:   call void @_ZNU3AS41CC2Ev(%class.C addrspace(4)* %this1) #4
+// CHECK:   call void @_ZNU3AS41CC2Ev(%class.C addrspace(4)* %this1)
 // CHECK:   ret void
 
 // CHECK-LABEL: @_Z12test__globalv()
@@ -74,13 +75,29 @@
 
 // Test the address space of 'this' when invoking a constructor.
 // CHECK:   %1 = addrspacecast %class.C* %c2 to %class.C addrspace(4)*
-// CHECK:   call void @_ZNU3AS41CC1Ev(%class.C addrspace(4)* %1) #4
+// CHECK:   call void @_ZNU3AS41CC1Ev(%class.C addrspace(4)* %1)
 
 // Test the address space of 'this' when invoking assignment operator.
 // CHECK:   %2 = addrspacecast %class.C* %c1 to %class.C addrspace(4)*
 // CHECK:   %3 = addrspacecast %class.C* %c2 to %class.C addrspace(4)*
 // CHECK:   %call2 = call dereferenceable(4) %class.C addrspace(4)* @_ZNU3AS41CaSERU3AS4KS_(%class.C addrspace(4)* %3, %class.C addrspace(4)* dereferenceable(4) %2)
 
+// Test the address space of 'this' when invoking the operator+
+// CHECK:   %4 = addrspacecast %class.C* %c1 to %class.C addrspace(4)*
+// CHECK:   %5 = addrspacecast %class.C* %c2 to %class.C addrspace(4)*
+// CHECK:   call void @_ZNU3AS41CplERU3AS4KS_(%class.C* sret %c3, %class.C addrspace(4)* %4, %class.C addrspace(4)* dereferenceable(4) %5)
+
+// Test the address space of 'this' when invoking the move constructor
+// CHECK:   %6 = addrspacecast %class.C* %c4 to %class.C addrspace(4)*
+// CHECK:   %call3 = call spir_func dereferenceable(4) %class.C addrspace(4)* @_Z3foov()
+// CHECK:   call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* %6, %class.C addrspace(4)* dereferenceable(4) %call3)
+
+// Test the address space of 'this' when invoking the move assignment
+// CHECK:   %7 = addrspacecast %class.C* %c5 to %class.C addrspace(4)*
+// CHECK:   %call4 = call spir_func dereferenceable(4) %class.C addrspace(4)* @_Z3foov() #5
+// CHECK:   call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* %7, %class.C addrspace(4)* dereferenceable(4) %call4)
+
+
 #define TEST(AS) \
   __kernel void test##AS() { \
 AS C c;  \
@@ -137,7 +154,7 @@
 // CHECK-LA

r350878 - fixup: sphinx warning

2019-01-10 Thread Nick Desaulniers via cfe-commits
Author: nickdesaulniers
Date: Thu Jan 10 11:26:35 2019
New Revision: 350878

URL: http://llvm.org/viewvc/llvm-project?rev=350878&view=rev
Log:
fixup: sphinx warning

Fixes the sphinx warning:
tools/clang/docs/DiagnosticsReference.rst:7889: WARNING: Title underline
too short.

That I just introduced in r350877.

Modified:
cfe/trunk/docs/DiagnosticsReference.rst

Modified: cfe/trunk/docs/DiagnosticsReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/DiagnosticsReference.rst?rev=350878&r1=350877&r2=350878&view=diff
==
--- cfe/trunk/docs/DiagnosticsReference.rst (original)
+++ cfe/trunk/docs/DiagnosticsReference.rst Thu Jan 10 11:26:35 2019
@@ -7886,7 +7886,7 @@ This diagnostic is enabled by default.
 
+---+---+
 
 -Woverride-init
---
+---
 Synonym for `-Winitializer-overrides`_.
 
 


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


  1   2   >