[PATCH] D61472: [X86FixupLEAs] Turn optIncDec into a generic two address LEA optimizer. Support LEA64_32r properly.

2019-05-05 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 198220.
craig.topper added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61472

Files:
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/warn-unsequenced.c
  clang/test/SemaCXX/warn-unsequenced.cpp
  llvm/lib/Target/X86/X86FixupLEAs.cpp
  llvm/test/CodeGen/X86/GlobalISel/add-ext.ll
  llvm/test/CodeGen/X86/GlobalISel/callingconv.ll
  llvm/test/CodeGen/X86/GlobalISel/gep.ll
  llvm/test/CodeGen/X86/GlobalISel/memop-scalar.ll
  llvm/test/CodeGen/X86/MergeConsecutiveStores.ll
  llvm/test/CodeGen/X86/atomic-unordered.ll
  llvm/test/CodeGen/X86/avx512vl-intrinsics-upgrade.ll
  llvm/test/CodeGen/X86/bitreverse.ll
  llvm/test/CodeGen/X86/bswap_tree2.ll
  llvm/test/CodeGen/X86/bypass-slow-division-32.ll
  llvm/test/CodeGen/X86/combine-srem.ll
  llvm/test/CodeGen/X86/dagcombine-shifts.ll
  llvm/test/CodeGen/X86/fixup-bw-copy.ll
  llvm/test/CodeGen/X86/fixup-lea.ll
  llvm/test/CodeGen/X86/imul.ll
  llvm/test/CodeGen/X86/leaFixup32.mir
  llvm/test/CodeGen/X86/leaFixup64.mir
  llvm/test/CodeGen/X86/mul-constant-i16.ll
  llvm/test/CodeGen/X86/mul-constant-i32.ll
  llvm/test/CodeGen/X86/mul-constant-i64.ll
  llvm/test/CodeGen/X86/mul-constant-i8.ll
  llvm/test/CodeGen/X86/popcnt.ll
  llvm/test/CodeGen/X86/reverse_branches.ll
  llvm/test/CodeGen/X86/rotate-extract.ll
  llvm/test/CodeGen/X86/sat-add.ll
  llvm/test/CodeGen/X86/twoaddr-lea.ll
  llvm/test/CodeGen/X86/vector-bitreverse.ll
  llvm/test/CodeGen/X86/win_coreclr_chkstk.ll
  llvm/test/Transforms/LoopStrengthReduce/X86/ivchain-X86.ll

Index: llvm/test/Transforms/LoopStrengthReduce/X86/ivchain-X86.ll
===
--- llvm/test/Transforms/LoopStrengthReduce/X86/ivchain-X86.ll
+++ llvm/test/Transforms/LoopStrengthReduce/X86/ivchain-X86.ll
@@ -243,14 +243,14 @@
 ; X32-NEXT:# =>This Inner Loop Header: Depth=1
 ; X32-NEXT:movl (%ebx,%esi), %ebp
 ; X32-NEXT:addl (%ebx), %ebp
-; X32-NEXT:leal (%ebx,%esi), %ebx
+; X32-NEXT:addl %esi, %ebx
 ; X32-NEXT:addl (%esi,%ebx), %ebp
-; X32-NEXT:leal (%ebx,%esi), %ebx
+; X32-NEXT:addl %esi, %ebx
 ; X32-NEXT:addl (%esi,%ebx), %ebp
-; X32-NEXT:leal (%ebx,%esi), %ebx
+; X32-NEXT:addl %esi, %ebx
 ; X32-NEXT:addl (%esi,%ebx), %ebp
 ; X32-NEXT:movl %ebp, (%edx)
-; X32-NEXT:leal (%ebx,%esi), %ebx
+; X32-NEXT:addl %esi, %ebx
 ; X32-NEXT:addl %edi, %ebx
 ; X32-NEXT:addl %ecx, %edx
 ; X32-NEXT:decl %eax
Index: llvm/test/CodeGen/X86/win_coreclr_chkstk.ll
===
--- llvm/test/CodeGen/X86/win_coreclr_chkstk.ll
+++ llvm/test/CodeGen/X86/win_coreclr_chkstk.ll
@@ -21,7 +21,7 @@
 ; WIN_X64:# %bb.1:
 ; WIN_X64:	andq	$-4096, %rdx
 ; WIN_X64:.LBB0_2:
-; WIN_X64:	leaq	-4096(%rcx), %rcx
+; WIN_X64:	addq	$-4096, %rcx
 ; WIN_X64:	movb	$0, (%rcx)
 ; WIN_X64:	cmpq	%rcx, %rdx
 ; WIN_X64:	jne	.LBB0_2
Index: llvm/test/CodeGen/X86/vector-bitreverse.ll
===
--- llvm/test/CodeGen/X86/vector-bitreverse.ll
+++ llvm/test/CodeGen/X86/vector-bitreverse.ll
@@ -27,7 +27,7 @@
 ; SSE-NEXT:addb %al, %al
 ; SSE-NEXT:andb $-86, %dil
 ; SSE-NEXT:shrb %dil
-; SSE-NEXT:leal (%rdi,%rax), %eax
+; SSE-NEXT:addl %edi, %eax
 ; SSE-NEXT:# kill: def $al killed $al killed $eax
 ; SSE-NEXT:retq
 ;
@@ -46,7 +46,7 @@
 ; AVX-NEXT:addb %al, %al
 ; AVX-NEXT:andb $-86, %dil
 ; AVX-NEXT:shrb %dil
-; AVX-NEXT:leal (%rdi,%rax), %eax
+; AVX-NEXT:addl %edi, %eax
 ; AVX-NEXT:# kill: def $al killed $al killed $eax
 ; AVX-NEXT:retq
 ;
Index: llvm/test/CodeGen/X86/twoaddr-lea.ll
===
--- llvm/test/CodeGen/X86/twoaddr-lea.ll
+++ llvm/test/CodeGen/X86/twoaddr-lea.ll
@@ -69,7 +69,7 @@
 
 bb3:
 ; CHECK: subl %e[[REG0:[a-z0-9]+]],
-; CHECK: leaq 4({{%[a-z0-9]+}}), %r[[REG0]]
+; CHECK: addq $4, %r[[REG0]]
   %tmp14 = phi i64 [ %tmp15, %bb5 ], [ 0, %bb1 ]
   %tmp15 = add nuw i64 %tmp14, 4
   %tmp16 = trunc i64 %tmp14 to i32
Index: llvm/test/CodeGen/X86/sat-add.ll
===
--- llvm/test/CodeGen/X86/sat-add.ll
+++ llvm/test/CodeGen/X86/sat-add.ll
@@ -236,7 +236,7 @@
 ; ANY-NEXT:notl %eax
 ; ANY-NEXT:cmpw %ax, %di
 ; ANY-NEXT:cmovbl %edi, %eax
-; ANY-NEXT:leal (%rax,%rsi), %eax
+; ANY-NEXT:addl %esi, %eax
 ; ANY-NEXT:# kill: def $ax killed $ax killed $eax
 ; ANY-NEXT:retq
   %noty = xor i16 %y, -1
@@ -287,7 +287,7 @@
 ; ANY-NEXT:notl %eax
 ; ANY-NEXT:cmpl %eax, %edi
 ; ANY-NEXT:cmovbl %edi, %eax

r360011 - P1286R2: Remove restriction that the exception specification of a

2019-05-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun May  5 22:04:56 2019
New Revision: 360011

URL: http://llvm.org/viewvc/llvm-project?rev=360011=rev
Log:
P1286R2: Remove restriction that the exception specification of a
defaulted special member matches the implicit exception specification.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
cfe/trunk/test/CXX/drs/dr17xx.cpp
cfe/trunk/test/CXX/except/except.spec/p14.cpp
cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
cfe/trunk/test/SemaCXX/member-init.cpp
cfe/trunk/test/SemaTemplate/exception-spec-crash.cpp
cfe/trunk/www/cxx_dr_status.html
cfe/trunk/www/cxx_status.html
cfe/trunk/www/make_cxx_dr_status

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=360011=360010=360011=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun May  5 22:04:56 
2019
@@ -7786,9 +7786,6 @@ def err_defaulted_special_member_copy_co
 def err_defaulted_copy_assign_not_ref : Error<
   "the parameter for an explicitly-defaulted copy assignment operator must be 
an "
   "lvalue reference type">;
-def err_incorrect_defaulted_exception_spec : Error<
-  "exception specification of explicitly defaulted "
-  "%sub{select_special_member_kind}0 does not match the calculated one">;
 def err_incorrect_defaulted_constexpr : Error<
   "defaulted definition of %sub{select_special_member_kind}0 "
   "is not constexpr">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=360011=360010=360011=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sun May  5 22:04:56 2019
@@ -682,16 +682,6 @@ public:
   SmallVector, 2>
 DelayedEquivalentExceptionSpecChecks;
 
-  /// All the members seen during a class definition which were both
-  /// explicitly defaulted and had explicitly-specified exception
-  /// specifications, along with the function type containing their
-  /// user-specified exception specification. Those exception specifications
-  /// were overridden with the default specifications, but we still need to
-  /// check whether they are compatible with the default specification, and
-  /// we can't do that until the nesting set of class definitions is complete.
-  SmallVector, 2>
-DelayedDefaultedMemberExceptionSpecs;
-
   typedef llvm::MapVector>
   LateParsedTemplateMapT;
@@ -6070,8 +6060,6 @@ public:
   void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD);
 
   void CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD);
-  void CheckExplicitlyDefaultedMemberExceptionSpec(CXXMethodDecl *MD,
-   const FunctionProtoType *T);
   void CheckDelayedMemberExceptionSpecs();
 
   
//======//
@@ -10999,9 +10987,6 @@ private:
  "there shouldn't be any pending delayed exception spec checks");
   assert(S.DelayedEquivalentExceptionSpecChecks.empty() &&
  "there shouldn't be any pending delayed exception spec checks");
-  assert(S.DelayedDefaultedMemberExceptionSpecs.empty() &&
- "there shouldn't be any pending delayed defaulted member "
- "exception specs");
   assert(S.DelayedDllExportClasses.empty() &&
  "there shouldn't be any pending delayed DLL export classes");
   swapSavedState();
@@ -11013,8 +10998,6 @@ private:
 SavedOverridingExceptionSpecChecks;
 decltype(DelayedEquivalentExceptionSpecChecks)
 SavedEquivalentExceptionSpecChecks;
-decltype(DelayedDefaultedMemberExceptionSpecs)
-SavedDefaultedMemberExceptionSpecs;
 decltype(DelayedDllExportClasses) SavedDllExportClasses;
 
 void swapSavedState() {
@@ -11022,8 +11005,6 @@ private:
   S.DelayedOverridingExceptionSpecChecks);
   SavedEquivalentExceptionSpecChecks.swap(
   S.DelayedEquivalentExceptionSpecChecks);
-  SavedDefaultedMemberExceptionSpecs.swap(
-  S.DelayedDefaultedMemberExceptionSpecs);
   SavedDllExportClasses.swap(S.DelayedDllExportClasses);
 }
   };

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=360011=360010=360011=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Sun May  5 22:04:56 2019
@@ -958,7 +958,6 @@ 

r360010 - Use DiagRuntimeBehavior for -Wunsequenced to weed out false positives

2019-05-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun May  5 21:14:01 2019
New Revision: 360010

URL: http://llvm.org/viewvc/llvm-project?rev=360010=rev
Log:
Use DiagRuntimeBehavior for -Wunsequenced to weed out false positives
where either the modification or the other access is unreachable.

This reverts r359984 (which reverted r359962). The bug in clang-tidy's
test suite exposed by the original commit was fixed in r360009.

Modified:
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/warn-unsequenced.c
cfe/trunk/test/SemaCXX/warn-unsequenced.cpp

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=360010=360009=360010=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Sun May  5 21:14:01 2019
@@ -84,11 +84,11 @@ class PossiblyUnreachableDiag {
 public:
   PartialDiagnostic PD;
   SourceLocation Loc;
-  const Stmt *stmt;
+  llvm::TinyPtrVector Stmts;
 
   PossiblyUnreachableDiag(const PartialDiagnostic , SourceLocation Loc,
-  const Stmt *stmt)
-  : PD(PD), Loc(Loc), stmt(stmt) {}
+  ArrayRef Stmts)
+  : PD(PD), Loc(Loc), Stmts(Stmts) {}
 };
 
 /// Retains information about a function, method, or block that is

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=360010=360009=360010=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sun May  5 21:14:01 2019
@@ -4252,6 +4252,10 @@ public:
   /// If it is unreachable, the diagnostic will not be emitted.
   bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
const PartialDiagnostic );
+  /// Similar, but diagnostic is only produced if all the specified statements
+  /// are reachable.
+  bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef Stmts,
+   const PartialDiagnostic );
 
   // Primary Expressions.
   SourceRange getExprRange(Expr *E) const;

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=360010=360009=360010=diff
==
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Sun May  5 21:14:01 2019
@@ -2089,16 +2089,16 @@ AnalysisBasedWarnings::IssueWarnings(sem
 
 // Register the expressions with the CFGBuilder.
 for (const auto  : fscope->PossiblyUnreachableDiags) {
-  if (D.stmt)
-AC.registerForcedBlockExpression(D.stmt);
+  for (const Stmt *S : D.Stmts)
+AC.registerForcedBlockExpression(S);
 }
 
 if (AC.getCFG()) {
   analyzed = true;
   for (const auto  : fscope->PossiblyUnreachableDiags) {
-bool processed = false;
-if (D.stmt) {
-  const CFGBlock *block = AC.getBlockForRegisteredExpression(D.stmt);
+bool AllReachable = true;
+for (const Stmt *S : D.Stmts) {
+  const CFGBlock *block = AC.getBlockForRegisteredExpression(S);
   CFGReverseBlockReachabilityAnalysis *cra =
   AC.getCFGReachablityAnalysis();
   // FIXME: We should be able to assert that block is non-null, but
@@ -2106,15 +2106,17 @@ AnalysisBasedWarnings::IssueWarnings(sem
   // edge cases; see test/Sema/vla-2.c.
   if (block && cra) {
 // Can this block be reached from the entrance?
-if (cra->isReachable(()->getEntry(), block))
-  S.Diag(D.Loc, D.PD);
-processed = true;
+if (!cra->isReachable(()->getEntry(), block)) {
+  AllReachable = false;
+  break;
+}
   }
+  // If we cannot map to a basic block, assume the statement is
+  // reachable.
 }
-if (!processed) {
-  // Emit the warning anyway if we cannot map to a basic block.
+
+if (AllReachable)
   S.Diag(D.Loc, D.PD);
-}
   }
 }
 

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=360010=360009=360010=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Sun May  5 21:14:01 2019
@@ -12155,10 +12155,11 @@ class SequenceChecker : public Evaluated
 if (OtherKind == UK_Use)
   std::swap(Mod, ModOrUse);
 
-

[clang-tools-extra] r360009 - Fix test to avoid assuming clang will diagnose problems in unreachable code.

2019-05-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun May  5 21:07:30 2019
New Revision: 360009

URL: http://llvm.org/viewvc/llvm-project?rev=360009=rev
Log:
Fix test to avoid assuming clang will diagnose problems in unreachable code.

Modified:
clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp

Modified: clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp?rev=360009=360008=360009=diff
==
--- clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp Sun May  5 
21:07:30 2019
@@ -171,6 +171,8 @@ TEST(DiagnosticsTest, ClangTidy) {
 #define $macrodef[[SQUARE]](X) (X)*(X)
 int main() {
   return $doubled[[sizeof]](sizeof(int));
+}
+int square() {
   int y = 4;
   return SQUARE($macroarg[[++]]y);
 }


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


[clang-tools-extra] r360007 - Fix up after r360006.

2019-05-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun May  5 21:00:45 2019
New Revision: 360007

URL: http://llvm.org/viewvc/llvm-project?rev=360007=rev
Log:
Fix up after r360006.

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

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp?rev=360007=360006=360007=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp Sun May  
5 21:00:45 2019
@@ -278,7 +278,7 @@ bool MakeSmartPtrCheck::replaceNew(Diagn
 return false;
 
   std::string ArraySizeExpr;
-  if (const auto* ArraySize = New->getArraySize()) {
+  if (const auto* ArraySize = New->getArraySize().getValueOr(nullptr)) {
 ArraySizeExpr = Lexer::getSourceText(CharSourceRange::getTokenRange(
  ArraySize->getSourceRange()),
  SM, getLangOpts())


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


r360006 - [c++20] Implement P1009R2: allow omitting the array bound in an array

2019-05-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun May  5 20:47:15 2019
New Revision: 360006

URL: http://llvm.org/viewvc/llvm-project?rev=360006=rev
Log:
[c++20] Implement P1009R2: allow omitting the array bound in an array
new expression.

This was voted into C++20 as a defect report resolution, so we
retroactively apply it to all prior language modes (though it can never
actually be used before C++11 mode).

Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/test/CodeGenCXX/new-array-init.cpp
cfe/trunk/test/PCH/cxx-exprs.cpp
cfe/trunk/test/SemaCXX/new-delete.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=360006=360005=360006=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Sun May  5 20:47:15 2019
@@ -2058,7 +2058,7 @@ private:
   CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
  FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
  bool UsualArrayDeleteWantsSize, ArrayRef PlacementArgs,
- SourceRange TypeIdParens, Expr *ArraySize,
+ SourceRange TypeIdParens, Optional ArraySize,
  InitializationStyle InitializationStyle, Expr *Initializer,
  QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
  SourceRange DirectInitRange);
@@ -2073,7 +2073,7 @@ public:
   Create(const ASTContext , bool IsGlobalNew, FunctionDecl *OperatorNew,
  FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
  bool UsualArrayDeleteWantsSize, ArrayRef PlacementArgs,
- SourceRange TypeIdParens, Expr *ArraySize,
+ SourceRange TypeIdParens, Optional ArraySize,
  InitializationStyle InitializationStyle, Expr *Initializer,
  QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
  SourceRange DirectInitRange);
@@ -2116,15 +2116,15 @@ public:
 
   bool isArray() const { return CXXNewExprBits.IsArray; }
 
-  Expr *getArraySize() {
-return isArray()
-   ? cast(getTrailingObjects()[arraySizeOffset()])
-   : nullptr;
+  Optional getArraySize() {
+if (!isArray())
+  return None;
+return cast_or_null(getTrailingObjects()[arraySizeOffset()]);
   }
-  const Expr *getArraySize() const {
-return isArray()
-   ? cast(getTrailingObjects()[arraySizeOffset()])
-   : nullptr;
+  Optional getArraySize() const {
+if (!isArray())
+  return None;
+return cast_or_null(getTrailingObjects()[arraySizeOffset()]);
   }
 
   unsigned getNumPlacementArgs() const {

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=360006=360005=360006=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Sun May  5 20:47:15 2019
@@ -1008,7 +1008,7 @@ protected:
 CastIterator(StmtPtr *I) : Base(I) {}
 
 typename Base::value_type operator*() const {
-  return cast(*this->I);
+  return cast_or_null(*this->I);
 }
   };
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=360006=360005=360006=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Sun May  5 20:47:15 2019
@@ -6413,8 +6413,8 @@ AST_MATCHER(CXXNewExpr, isArray) {
 /// cxxNewExpr(hasArraySize(intgerLiteral(equals(10
 ///   matches the expression 'new MyClass[10]'.
 AST_MATCHER_P(CXXNewExpr, hasArraySize, internal::Matcher, InnerMatcher) 
{
-  return Node.isArray() &&
-InnerMatcher.matches(*Node.getArraySize(), Finder, Builder);
+  return Node.isArray() && *Node.getArraySize() &&
+ InnerMatcher.matches(**Node.getArraySize(), Finder, Builder);
 }
 
 /// Matches a class declaration that is defined.

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 

[PATCH] D61345: Allow 'CodeGenObjC/illegal-UTF8.m' test for 32-bit targets.

2019-05-05 Thread Galina via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360005: The CodeGenObjC/illegal-UTF8.m get 
failed with Clang built with 32-bit… (authored by gkistanova, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61345?vs=197438=198217#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61345

Files:
  cfe/trunk/test/CodeGenObjC/illegal-UTF8.m


Index: cfe/trunk/test/CodeGenObjC/illegal-UTF8.m
===
--- cfe/trunk/test/CodeGenObjC/illegal-UTF8.m
+++ cfe/trunk/test/CodeGenObjC/illegal-UTF8.m
@@ -1,4 +1,4 @@
-// RUN: %clang %s -S -m64 -o -
+// RUN: %clang %s -S -o -
 
 @class NSString;
 


Index: cfe/trunk/test/CodeGenObjC/illegal-UTF8.m
===
--- cfe/trunk/test/CodeGenObjC/illegal-UTF8.m
+++ cfe/trunk/test/CodeGenObjC/illegal-UTF8.m
@@ -1,4 +1,4 @@
-// RUN: %clang %s -S -m64 -o -
+// RUN: %clang %s -S -o -
 
 @class NSString;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r360005 - The 'CodeGenObjC/illegal-UTF8.m' get failed with Clang built with 32-bit targets only (as example ARM-only) with the following error:

2019-05-05 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Sun May  5 20:30:09 2019
New Revision: 360005

URL: http://llvm.org/viewvc/llvm-project?rev=360005=rev
Log:
The 'CodeGenObjC/illegal-UTF8.m' get failed with Clang built with 32-bit 
targets only (as example ARM-only) with the following error:

error: unable to create target: 'No available targets are compatible with 
triple "< ... any 64-bit target triple ... >"'

I didn't find any 64-bit dependencies for the test and I think removing '-m64' 
option should fix the problem and allow this test for any target specified by 
LLVM_DEFAULT_TARGET_TRIPLE.

Patch by Vlad Vereschaka.

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


Modified:
cfe/trunk/test/CodeGenObjC/illegal-UTF8.m

Modified: cfe/trunk/test/CodeGenObjC/illegal-UTF8.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/illegal-UTF8.m?rev=360005=360004=360005=diff
==
--- cfe/trunk/test/CodeGenObjC/illegal-UTF8.m (original)
+++ cfe/trunk/test/CodeGenObjC/illegal-UTF8.m Sun May  5 20:30:09 2019
@@ -1,4 +1,4 @@
-// RUN: %clang %s -S -m64 -o -
+// RUN: %clang %s -S -o -
 
 @class NSString;
 


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


[PATCH] D61509: [PragmaHandler][OpenMP] Expose `#pragma` location

2019-05-05 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.



In D61509#1491209 , @ABataev wrote:

> In D61509#1491204 , @lebedev.ri 
> wrote:
>
> > In D61509#1491158 , @jdenny wrote:
> >
> > > In D61509#1491119 , @lebedev.ri 
> > > wrote:
> > >
> > > > I recommend to split this into two parts - changing 
> > > > `PragmaIntroducerKind Introducer` to
> > > >  `struct NameMe { PragmaIntroducerKind Kind; SourceLocation Loc};`, and 
> > > > the actual openmp change.
> > >
> > >
> > > Sure, I'll work on that.  What about NameMe = PragmaIntroducer?
> >
> >
> > Could work. And then move `PragmaIntroducerKind` into it.
> >  I believe this part of the refactoring is completely uncontroversial.
> >
> > >> For that change, just basing off the clang-tidy diff, neither variant is 
> > >> ideal,
> > > 
> > > Do you mean that it's better for diagnostics that point to a pragma not 
> > > to include the `#pragma` in their locations?  If so, why is that?
> >
> > I'm not sure either one is better than the other one.
> >
> > I have two concerns:
> >
> > - I fear this would result in inconsistency with other pragmas, since this 
> > will only change openmp-ones. I don't know if it will be accepted to 
> > migrate the rest of them in the same way.
> > - This use-case requires having the location of `#pragma`, so the entire 
> > AST is migrating to store it. But the current location will no longer be 
> > accessible from AST.
> >
> >   I see two paths forward:
> > - Mail cfe-dev, and suggest to do this change for *all* pragmas. Either 
> > this is ok for all of them, or none of them.
> > - Moar abstractions - how about **not** changing the startloc of openmp 
> > directives,
>


My alternative proposal was exactly that.  A difficulty is how to pass the 
`#pragma` location to the OpenMP AST node constructors.  
`PragmaOpenMPHandler::HandlePragma` passes locations via the 
`tok::annot_pragma_openmp` and `tok::annot_pragma_openmp_end` tokens, so where 
do we pass this new location?  I proposed creating a third token, and Alexey 
was concerned over the parsing problems that would create.

>>   but instead add some baseclass to `OMPDirective` class (& every other 
>> class that is created from pragma), that would record the `PragmaIntroducer`?

I agree that a base class would be a nice way to extend all pragma classes with 
the `PragmaIntroducer`.

> I'm against this solution. I don't see any reasons why we should do this. 
> Instead, we're getting a lot of pain with parsing and maintenance.

One way to avoid creating an extra token would be to widen the `Token` class to 
store the additional location.  The `Token` documentation says it's not 
intended to be space efficient.  How does that sound to people?


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

https://reviews.llvm.org/D61509



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


[PATCH] D61559: Fix the crash when formatting unsupported encodings

2019-05-05 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 198205.
owenpan added a comment.

Moved "UTF-32 (LE)" to before "UTF-16 (LE)" in `llvm::StringSwitch` so that the 
former BOM wouldn't be misnamed as the latter.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61559

Files:
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -257,6 +257,36 @@
   std::unique_ptr Code = std::move(CodeOrErr.get());
   if (Code->getBufferSize() == 0)
 return false; // Empty files are formatted correctly.
+
+  // Check to see if the buffer has a UTF Byte Order Mark (BOM).
+  // We only support UTF-8 with and without a BOM right now.  See
+  // https://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding
+  // for more information.
+  StringRef BufStr = Code->getBuffer();
+  const char *InvalidBOM = llvm::StringSwitch(BufStr)
+.StartsWith(llvm::StringLiteral::withInnerNUL("\x00\x00\xFE\xFF"),
+  "UTF-32 (BE)")
+.StartsWith(llvm::StringLiteral::withInnerNUL("\xFF\xFE\x00\x00"),
+  "UTF-32 (LE)")
+.StartsWith("\xFE\xFF", "UTF-16 (BE)")
+.StartsWith("\xFF\xFE", "UTF-16 (LE)")
+.StartsWith("\x2B\x2F\x76", "UTF-7")
+.StartsWith("\xF7\x64\x4C", "UTF-1")
+.StartsWith("\xDD\x73\x66\x73", "UTF-EBCDIC")
+.StartsWith("\x0E\xFE\xFF", "SDSU")
+.StartsWith("\xFB\xEE\x28", "BOCU-1")
+.StartsWith("\x84\x31\x95\x33", "GB-18030")
+.Default(nullptr);
+
+  if (InvalidBOM) {
+errs() << "error: encoding with unsupported byte order mark \""
+   << InvalidBOM << "\" detected";
+if (FileName != "-")
+  errs() << " in file '" << FileName << "'";
+errs() << ".\n";
+return true;
+  }
+
   std::vector Ranges;
   if (fillRanges(Code.get(), Ranges))
 return true;


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -257,6 +257,36 @@
   std::unique_ptr Code = std::move(CodeOrErr.get());
   if (Code->getBufferSize() == 0)
 return false; // Empty files are formatted correctly.
+
+  // Check to see if the buffer has a UTF Byte Order Mark (BOM).
+  // We only support UTF-8 with and without a BOM right now.  See
+  // https://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding
+  // for more information.
+  StringRef BufStr = Code->getBuffer();
+  const char *InvalidBOM = llvm::StringSwitch(BufStr)
+.StartsWith(llvm::StringLiteral::withInnerNUL("\x00\x00\xFE\xFF"),
+  "UTF-32 (BE)")
+.StartsWith(llvm::StringLiteral::withInnerNUL("\xFF\xFE\x00\x00"),
+  "UTF-32 (LE)")
+.StartsWith("\xFE\xFF", "UTF-16 (BE)")
+.StartsWith("\xFF\xFE", "UTF-16 (LE)")
+.StartsWith("\x2B\x2F\x76", "UTF-7")
+.StartsWith("\xF7\x64\x4C", "UTF-1")
+.StartsWith("\xDD\x73\x66\x73", "UTF-EBCDIC")
+.StartsWith("\x0E\xFE\xFF", "SDSU")
+.StartsWith("\xFB\xEE\x28", "BOCU-1")
+.StartsWith("\x84\x31\x95\x33", "GB-18030")
+.Default(nullptr);
+
+  if (InvalidBOM) {
+errs() << "error: encoding with unsupported byte order mark \""
+   << InvalidBOM << "\" detected";
+if (FileName != "-")
+  errs() << " in file '" << FileName << "'";
+errs() << ".\n";
+return true;
+  }
+
   std::vector Ranges;
   if (fillRanges(Code.get(), Ranges))
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43500: [clang-tidy]: modernize-use-default-member-init: Remove trailing comma and colon.

2019-05-05 Thread Christian Gagneraud via Phabricator via cfe-commits
chgans added a comment.

Hi, Using llvm-8 (llvm ubuntu repo), clang-replacement has improved, but there 
still a case when a comma is left beyond: if there was only one member init.


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

https://reviews.llvm.org/D43500



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


[PATCH] D61570: [analyzer] PR41753: Include complex integer types in NonLoc::isCompoundType

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

Yup, this definitely deserves to be a compound value. Could you also add a test 
that tries to load real/imaginary parts of `y` and compares them to 1? Just to 
know whether it actually works or just pretends to.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61570



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


[clang-tools-extra] r360002 - [clang-tidy] openmp-exception-escape check: point to the structured-block

2019-05-05 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Sun May  5 14:26:32 2019
New Revision: 360002

URL: http://llvm.org/viewvc/llvm-project?rev=360002=rev
Log:
[clang-tidy] openmp-exception-escape check: point to the structured-block

I'm not sure what i was thinking when i wrote it to point at the directive.
It's at the very least confusing, and in the `for` is very misleading.

We should point at the actual Stmt out of which the exception escapes,
to highlight where it should be fixed e.g. via adding try-catch block.

Yes, this breaks existing NOLINT, which is why this change needs to
happen now, not any later.

Modified:
clang-tools-extra/trunk/clang-tidy/openmp/ExceptionEscapeCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/openmp-exception-escape.cpp

Modified: clang-tools-extra/trunk/clang-tidy/openmp/ExceptionEscapeCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/openmp/ExceptionEscapeCheck.cpp?rev=360002=360001=360002=diff
==
--- clang-tools-extra/trunk/clang-tidy/openmp/ExceptionEscapeCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/openmp/ExceptionEscapeCheck.cpp Sun May  
5 14:26:32 2019
@@ -73,7 +73,7 @@ void ExceptionEscapeCheck::check(const M
   // FIXME: We should provide more information about the exact location where
   // the exception is thrown, maybe the full path the exception escapes.
 
-  diag(Directive->getBeginLoc(),
+  diag(StructuredBlock->getBeginLoc(),
"an exception thrown inside of the OpenMP '%0' region is not caught in "
"that same region")
   << getOpenMPDirectiveName(Directive->getDirectiveKind());

Modified: clang-tools-extra/trunk/test/clang-tidy/openmp-exception-escape.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/openmp-exception-escape.cpp?rev=360002=360001=360002=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/openmp-exception-escape.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/openmp-exception-escape.cpp Sun May 
 5 14:26:32 2019
@@ -13,7 +13,7 @@ class bad_alloc {};
 void parallel() {
 #pragma omp parallel
   thrower();
-  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: an exception thrown inside of 
the OpenMP 'parallel' region is not caught in that same region
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception thrown inside of 
the OpenMP 'parallel' region is not caught in that same region
 }
 
 void ignore() {
@@ -57,7 +57,7 @@ void forloop(const int a) {
 #pragma omp for
   for (int i = 0; i < a; i++)
 thrower();
-  // CHECK-MESSAGES: :[[@LINE-3]]:9: warning: an exception thrown inside of 
the OpenMP 'for' region is not caught in that same region
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception thrown inside of 
the OpenMP 'for' region is not caught in that same region
 }
 
 void parallel_forloop(const int a) {
@@ -67,8 +67,8 @@ void parallel_forloop(const int a) {
 for (int i = 0; i < a; i++)
   thrower();
 thrower();
-// CHECK-MESSAGES: :[[@LINE-6]]:9: warning: an exception thrown inside of 
the OpenMP 'parallel' region is not caught in that same region
-// CHECK-MESSAGES: :[[@LINE-5]]:9: warning: an exception thrown inside of 
the OpenMP 'for' region is not caught in that same region
+// CHECK-MESSAGES: :[[@LINE-5]]:3: warning: an exception thrown inside of 
the OpenMP 'parallel' region is not caught in that same region
+// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: an exception thrown inside of 
the OpenMP 'for' region is not caught in that same region
   }
 }
 
@@ -83,7 +83,7 @@ void parallel_forloop_caught(const int a
   }
 }
 thrower();
-// CHECK-MESSAGES: :[[@LINE-10]]:9: warning: an exception thrown inside of 
the OpenMP 'parallel' region is not caught in that same region
+// CHECK-MESSAGES: :[[@LINE-9]]:3: warning: an exception thrown inside of 
the OpenMP 'parallel' region is not caught in that same region
   }
 }
 
@@ -97,7 +97,7 @@ void parallel_caught_forloop(const int a
   thrower();
 } catch (...) {
 }
-// CHECK-MESSAGES: :[[@LINE-7]]:9: warning: an exception thrown inside of 
the OpenMP 'for' region is not caught in that same region
+// CHECK-MESSAGES: :[[@LINE-5]]:7: warning: an exception thrown inside of 
the OpenMP 'for' region is not caught in that same region
   }
 }
 
@@ -111,7 +111,7 @@ void parallel_outercaught_forloop(const
   thrower();
 } catch (...) {
 }
-// CHECK-MESSAGES: :[[@LINE-6]]:9: warning: an exception thrown inside of 
the OpenMP 'for' region is not caught in that same region
+// CHECK-MESSAGES: :[[@LINE-4]]:9: warning: an exception thrown inside of 
the OpenMP 'for' region is not caught in that same region
   }
 }
 


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

[PATCH] D40381: Parse concept definition

2019-05-05 Thread Saar Raz via Phabricator via cfe-commits
saar.raz added a comment.

Awesome! I do not have commit permissions though, so can you do the actual 
commit?


Repository:
  rC Clang

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

https://reviews.llvm.org/D40381



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


[PATCH] D40381: Parse concept definition

2019-05-05 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 198200.
saar.raz marked 4 inline comments as done.
saar.raz added a comment.

- Address final CR comments by rsmith


Repository:
  rC Clang

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

https://reviews.llvm.org/D40381

Files:
  include/clang/AST/ASTNodeTraverser.h
  include/clang/AST/DeclTemplate.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/TextNodeDumper.h
  include/clang/Basic/DeclNodes.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TemplateKinds.h
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTStructuralEquivalence.cpp
  lib/AST/DeclBase.cpp
  lib/AST/DeclPrinter.cpp
  lib/AST/DeclTemplate.cpp
  lib/AST/TextNodeDumper.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Index/IndexDecl.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
  test/Parser/cxx-concept-declaration.cpp
  test/Parser/cxx-concepts-ambig-constraint-expr.cpp
  test/Parser/cxx-concepts-requires-clause.cpp
  test/Parser/cxx2a-concept-declaration.cpp
  test/Parser/cxx2a-concepts-ambig-constraint-expr.cpp
  test/Parser/cxx2a-concepts-requires-clause.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -6252,6 +6252,7 @@
   case Decl::PragmaComment:
   case Decl::PragmaDetectMismatch:
   case Decl::UsingPack:
+  case Decl::Concept:
 return C;
 
   // Declaration kinds that don't make any sense here, but are
Index: test/Parser/cxx-concepts-requires-clause.cpp
===
--- /dev/null
+++ test/Parser/cxx-concepts-requires-clause.cpp
@@ -1,82 +0,0 @@
-// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ %s -verify
-// expected-no-diagnostics
-
-// Test parsing of the optional requires-clause in a template-declaration.
-
-template  requires true
-void foo() { }
-
-
-template  requires !0
-struct A {
-  void foo();
-  struct AA;
-  enum E : int;
-  static int x;
-
-  template  requires true
-  void Mfoo();
-
-  template  requires true
-  struct M;
-
-  template  requires true
-  static int Mx;
-
-  template  requires true
-  using MQ = M;
-};
-
-template  requires !0
-void A::foo() { }
-
-template  requires !0
-struct A::AA { };
-
-template  requires !0
-enum A::E : int { E0 };
-
-template  requires !0
-int A::x = 0;
-
-template  requires !0
-template  requires true
-void A::Mfoo() { }
-
-template  requires !0
-template  requires true
-struct A::M { };
-
-template  requires !0
-template  requires true
-int A::Mx = 0;
-
-
-template  requires true
-int x = 0;
-
-template  requires true
-using Q = A;
-
-struct C {
-  template  requires true
-  void Mfoo();
-
-  template  requires true
-  struct M;
-
-  template  requires true
-  static int Mx;
-
-  template  requires true
-  using MQ = M;
-};
-
-template  requires true
-void C::Mfoo() { }
-
-template  requires true
-struct C::M { };
-
-template  requires true
-int C::Mx = 0;
Index: test/Parser/cxx-concepts-ambig-constraint-expr.cpp
===
--- /dev/null
+++ test/Parser/cxx-concepts-ambig-constraint-expr.cpp
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ %s -verify
-
-// Test parsing of constraint-expressions in cases where the grammar is
-// ambiguous with the expectation that the longest token sequence which matches
-// the syntax is consumed without backtracking.
-
-// type-specifier-seq in conversion-type-id
-template  requires (bool)::operator short
-unsigned int foo(); // expected-error {{C++ requires a type specifier for all declarations}}
-
-// type-specifier-seq in new-type-id
-template  requires (bool)sizeof new (T::f()) short
-unsigned int bar(); // expected-error {{C++ requires a type specifier for all declarations}}
-
-template requires (bool)sizeof new (T::f()) unsigned // expected-error {{'struct' cannot be signed or unsigned}}
-struct X { }; // expected-error {{'X' cannot be defined in a type specifier}}
-
-// C-style cast
-// of function call on function-style cast
-template  requires (bool(T()))
-T (*fp)(); // expected-error {{use of undeclared identifier 'fp'}}
-
-// function-style cast
-// as the callee in a function call
-struct A {
-  static int t;
-  template  requires bool(T())
-  (A(T ())) { } // expected-error {{called object type 'bool' is not a function or function pointer}}
-};
Index: test/Parser/cxx2a-concept-declaration.cpp

[PATCH] D61569: [analyzer][UninitializedObjectChecker] PR41741: Regard all scalar types as primitive.

2019-05-05 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC359998: [analyzer][UninitializedObjectChecker] PR41741: 
Regard all scalar types as… (authored by Szelethus, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D61569

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
  test/Analysis/cxx-uninitialized-object.cpp


Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1,11 +1,15 @@
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,optin.cplusplus.UninitializedObject \
+// RUN: %clang_analyze_cc1 -std=c++14 -verify  %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=optin.cplusplus.UninitializedObject \
 // RUN:   -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true 
-DPEDANTIC \
-// RUN:   -analyzer-config 
optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN:   -std=c++14 -verify  %s
+// RUN:   -analyzer-config \
+// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true
 
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,optin.cplusplus.UninitializedObject \
-// RUN:   -analyzer-config 
optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN:   -std=c++14 -verify  %s
+// RUN: %clang_analyze_cc1 -std=c++14 -verify  %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=optin.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config \
+// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true
 
 
//===--===//
 // Default constructor test.
@@ -1156,3 +1160,28 @@
   VectorSizeLong v;
   v.x[0] = 0;
 }
+
+struct ComplexUninitTest {
+  ComplexUninitTest() {}
+  __complex__ float x;
+  __complex__ int y;
+};
+
+// FIXME: Currently this causes (unrelated to this checker) an assertion
+// failure.
+//
+//struct ComplexInitTest {
+//  ComplexInitTest() {
+//x = {1.0f, 1.0f};
+//y = {1, 1};
+//  }
+//  __complex__ float x;
+//  __complex__ int y;
+//};
+
+void fComplexTest() {
+//  ComplexInitTest x;
+
+  // TODO: we should emit a warning for x2.x and x2.y.
+  ComplexUninitTest x2;
+}
Index: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
===
--- lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
+++ lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
@@ -323,9 +323,8 @@
 /// needs to be analyzed as much as checking whether their value is undefined.
 inline bool isPrimitiveType(const QualType ) {
   return T->isBuiltinType() || T->isEnumeralType() ||
- T->isMemberPointerType() || T->isBlockPointerType() ||
  T->isFunctionType() || T->isAtomicType() ||
- T->isVectorType();
+ T->isVectorType() || T->isScalarType();
 }
 
 inline bool isDereferencableType(const QualType ) {


Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1,11 +1,15 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject \
+// RUN: %clang_analyze_cc1 -std=c++14 -verify  %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=optin.cplusplus.UninitializedObject \
 // RUN:   -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
-// RUN:   -analyzer-config optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN:   -std=c++14 -verify  %s
+// RUN:   -analyzer-config \
+// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true
 
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject \
-// RUN:   -analyzer-config optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN:   -std=c++14 -verify  %s
+// RUN: %clang_analyze_cc1 -std=c++14 -verify  %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=optin.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config \
+// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true
 
 //===--===//
 // Default constructor test.
@@ -1156,3 +1160,28 @@
   VectorSizeLong v;
   v.x[0] = 0;
 }
+
+struct ComplexUninitTest {
+  ComplexUninitTest() {}
+  __complex__ float x;
+  __complex__ int y;
+};
+
+// FIXME: Currently this causes (unrelated to this checker) an assertion
+// failure.
+//
+//struct ComplexInitTest {
+//  ComplexInitTest() {
+//x = {1.0f, 1.0f};
+//y = {1, 1};
+//  }
+//  __complex__ float 

r359998 - [analyzer][UninitializedObjectChecker] PR41741: Regard all scalar types as primitive.

2019-05-05 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Sun May  5 12:42:33 2019
New Revision: 359998

URL: http://llvm.org/viewvc/llvm-project?rev=359998=rev
Log:
[analyzer][UninitializedObjectChecker] PR41741: Regard all scalar types as 
primitive.

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

Pretty much the same as D61246 and D61106, this time for __complex__ types. Upon
further investigation, I realized that we should regard all types
Type::isScalarType returns true for as primitive, so I merged 
isMemberPointerType(), isBlockPointerType() and isAnyComplexType()` into that
instead.

I also stumbled across yet another bug,
https://bugs.llvm.org/show_bug.cgi?id=41753, but it seems to be unrelated to
this checker.

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

Modified:

cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h?rev=359998=359997=359998=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h 
Sun May  5 12:42:33 2019
@@ -323,9 +323,8 @@ private:
 /// needs to be analyzed as much as checking whether their value is undefined.
 inline bool isPrimitiveType(const QualType ) {
   return T->isBuiltinType() || T->isEnumeralType() ||
- T->isMemberPointerType() || T->isBlockPointerType() ||
  T->isFunctionType() || T->isAtomicType() ||
- T->isVectorType();
+ T->isVectorType() || T->isScalarType();
 }
 
 inline bool isDereferencableType(const QualType ) {

Modified: cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp?rev=359998=359997=359998=diff
==
--- cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp (original)
+++ cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp Sun May  5 12:42:33 
2019
@@ -1,11 +1,15 @@
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,optin.cplusplus.UninitializedObject \
+// RUN: %clang_analyze_cc1 -std=c++14 -verify  %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=optin.cplusplus.UninitializedObject \
 // RUN:   -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true 
-DPEDANTIC \
-// RUN:   -analyzer-config 
optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN:   -std=c++14 -verify  %s
+// RUN:   -analyzer-config \
+// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true
 
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,optin.cplusplus.UninitializedObject \
-// RUN:   -analyzer-config 
optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN:   -std=c++14 -verify  %s
+// RUN: %clang_analyze_cc1 -std=c++14 -verify  %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=optin.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config \
+// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true
 
 
//===--===//
 // Default constructor test.
@@ -1156,3 +1160,28 @@ void __vector_size__LongTest() {
   VectorSizeLong v;
   v.x[0] = 0;
 }
+
+struct ComplexUninitTest {
+  ComplexUninitTest() {}
+  __complex__ float x;
+  __complex__ int y;
+};
+
+// FIXME: Currently this causes (unrelated to this checker) an assertion
+// failure.
+//
+//struct ComplexInitTest {
+//  ComplexInitTest() {
+//x = {1.0f, 1.0f};
+//y = {1, 1};
+//  }
+//  __complex__ float x;
+//  __complex__ int y;
+//};
+
+void fComplexTest() {
+//  ComplexInitTest x;
+
+  // TODO: we should emit a warning for x2.x and x2.y.
+  ComplexUninitTest x2;
+}


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


[PATCH] D33841: [clang-tidy] redundant keyword check

2019-05-05 Thread Daniel Kolozsvari via Phabricator via cfe-commits
koldaniel updated this revision to Diff 198194.
koldaniel added a comment.

Typedef and macro maches fixed, new test cases added.


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

https://reviews.llvm.org/D33841

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantExternCheck.cpp
  clang-tidy/readability/RedundantExternCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/readability-redundant-extern.rst
  test/clang-tidy/readability-redundant-extern.cpp

Index: test/clang-tidy/readability-redundant-extern.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-extern.cpp
@@ -0,0 +1,74 @@
+// RUN: %check_clang_tidy %s readability-redundant-extern %t
+
+extern int f();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: int f();
+
+int extern f() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: int f() { return 0; }
+
+extern "C" int g();
+// CHECK-FIXES: extern "C" int g();
+
+extern "C" int g() { return 0; }
+// CHECK-FIXES: extern "C" int g() { return 0; }
+
+extern "C++" int h();
+// CHECK-FIXES: extern "C++" int h();
+
+extern "C++" int h() { return 0; }
+// CHECK-FIXES: extern "C++" int h() { return 0; }
+
+inline extern void foo_inline();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: inline void foo_inline();
+
+#define FOO_EXTERN extern
+FOO_EXTERN void foo_macro_1();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: FOO_EXTERN void foo_macro_1();
+
+#define FOO_INLINE inline
+FOO_INLINE extern void foo_macro_2();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: FOO_INLINE extern void foo_macro_2();
+
+#define FOO_EXTERN_INLINE inline extern
+FOO_EXTERN_INLINE void foo_macro_3();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: FOO_EXTERN_INLINE void foo_macro_3();
+
+void file_scope();
+// CHECK-FIXES: void file_scope();
+
+void another_file_scope(int _extern);
+// CHECK-FIXES: void another_file_scope(int _extern);
+
+namespace {
+extern void namespace_1();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: void namespace_1();
+}
+
+namespace a {
+namespace {
+namespace b {
+extern void namespace_2();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: void namespace_2();
+}
+}
+}
+
+namespace {
+extern "C" void namespace_3();
+// CHECK-FIXES: extern "C" void namespace_3();
+}
+
+#define FOO_EXTERN extern
+typedef int extern_int;
+
+extern_int FOO_EXTERN typedef_extern_foo();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: extern_int FOO_EXTERN typedef_extern_foo();
Index: docs/clang-tidy/checks/readability-redundant-extern.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-redundant-extern.rst
@@ -0,0 +1,15 @@
+.. title:: clang-tidy - readability-redundant-extern
+
+readability-redundant-extern
+
+
+Removes the redundant ``extern`` keywords from code.
+
+``extern`` is redundant in function declarations
+
+The default language linkage is C++, so without any additional parameters it is redundant (extern "C++" can also be redundant, but it depends on the context). In C context (extern "C") the situation is the same, extern keyword is redundant for function declarations
+
+.. code-block:: c++
+
+  extern void h();
+
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -164,6 +164,11 @@
   but either don't specify it or the clause is specified but with the kind
   other than ``none``, and suggests to use the ``default(none)`` clause.
 
+- New :doc:`readability-redundant-extern
+  ` check.
+
+  Removes the redundant ``extern`` keywords.
+
 Improvements to clang-include-fixer
 ---
 
Index: clang-tidy/readability/RedundantExternCheck.h
===
--- /dev/null
+++ clang-tidy/readability/RedundantExternCheck.h
@@ -0,0 +1,34 @@
+//===--- RedundantExternCheck.h - clang-tidy *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//

[PATCH] D33841: [clang-tidy] redundant keyword check

2019-05-05 Thread Daniel Kolozsvari via Phabricator via cfe-commits
koldaniel marked an inline comment as done.
koldaniel added inline comments.



Comment at: test/clang-tidy/readability-redundant-extern.cpp:37
+
+void another_file_scope(int _extern);

aaron.ballman wrote:
> More tests that I figured out:
> ```
> namespace {
> extern void f(); // 'extern' is not redundant
> }
> 
> namespace a {
> namespace {
> namespace b {
> extern void f(); // 'extern' is not redundant
> }
> }
> }
> 
> // Note, the above are consequences of http://eel.is/c++draft/basic.link#6
> 
> #define FOO_EXTERN extern
> typedef int extern_int;
> 
> extern_int FOO_EXTERN foo(); // 'extern' is redundant, but hopefully we don't 
> try to fixit this to be '_int FOO_EXTERN foo();'
> 
> // The above is a weird consequence of how specifiers are parsed in C and C++
> ```
In the first two examples extern is redundant:

"An unnamed namespace or a namespace declared directly or indirectly within an 
unnamed namespace has internal linkage. All other namespaces have external 
linkage."

Also, based on the examples in http://eel.is/c++draft/basic.link#8 , the extern 
keyword has no effect in case of unnamed namespaces. In case of 'C' linkage 
defined by an extern keyword the checker does not warn.



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

https://reviews.llvm.org/D33841



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-05-05 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:10364
+  if (const auto *FD = dyn_cast(D)) {
+if (OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(FD)) {
+  HasEmittedDeclareTargetRegion = true;

ABataev wrote:
> ABataev wrote:
> > No need for the braces
> What if `declare target` is used only for variabes but not for the functions?
Even more reason to error in that case since it may contain clauses like link 
or to which need for requires directives to be used consistently.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

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

In D36357#1491081 , @Rakete wrote:

> @rsmith One last question: The fixit diagnostic seems to be inconsistent with 
> the rest?
>
>   main.cpp:2:3: error: '[]' after delete interpreted as 'delete[]'
> delete[] { return new int; }
> ^~~~
>   ( )
>
>
> Shouldn't the `^~~` be starting at the `[]`?


Pointing the caret at the `[` might be clearer, but I think that's fine too.

In D36357#1491082 , @Rakete wrote:

> Is this also okay?
>
>   main.cpp:2:9: warning: lambda expressions are incompatible with C++98 
> [-Wc++98-compat]
> delete[] { return new int; }
>   ^
>   main.cpp:2:3: error: '[]' after delete interpreted as 'delete[]'; add 
> parentheses to treat this as a lambda-expression
> delete[] { return new int; }
> ^~~~
>   ( )
>


Hmm. It would be better to produce the error first, but that would make it more 
difficult to get the fixit hint right. I suppose in the case where we've 
already decided we're going to diagnose, we could perform a tentative parse and 
skip to the `}` of the lambda.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36357



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


[PATCH] D61519: [clangd] Support -fallback-style, similar to clang-format.

2019-05-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM

Putting http://lists.llvm.org/pipermail/clangd-dev/2019-May/000411.html here 
for context.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61519



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


[PATCH] D60552: [X86] Enable intrinsics of AVX512_BF16, which are supported for BFLOAT16 in Cooper Lake

2019-05-05 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D60552



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


r359984 - Revert rL359962 : Use DiagRuntimeBehavior for -Wunsequenced to weed out false positives

2019-05-05 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Sun May  5 10:10:05 2019
New Revision: 359984

URL: http://llvm.org/viewvc/llvm-project?rev=359984=rev
Log:
Revert rL359962 : Use DiagRuntimeBehavior for -Wunsequenced to weed out false 
positives
where either the modification or the other access is unreachable.

Try to fix buildbots

Modified:
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/warn-unsequenced.c
cfe/trunk/test/SemaCXX/warn-unsequenced.cpp

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=359984=359983=359984=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Sun May  5 10:10:05 2019
@@ -84,11 +84,11 @@ class PossiblyUnreachableDiag {
 public:
   PartialDiagnostic PD;
   SourceLocation Loc;
-  llvm::TinyPtrVector Stmts;
+  const Stmt *stmt;
 
   PossiblyUnreachableDiag(const PartialDiagnostic , SourceLocation Loc,
-  ArrayRef Stmts)
-  : PD(PD), Loc(Loc), Stmts(Stmts) {}
+  const Stmt *stmt)
+  : PD(PD), Loc(Loc), stmt(stmt) {}
 };
 
 /// Retains information about a function, method, or block that is

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=359984=359983=359984=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sun May  5 10:10:05 2019
@@ -4252,10 +4252,6 @@ public:
   /// If it is unreachable, the diagnostic will not be emitted.
   bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement,
const PartialDiagnostic );
-  /// Similar, but diagnostic is only produced if all the specified statements
-  /// are reachable.
-  bool DiagRuntimeBehavior(SourceLocation Loc, ArrayRef Stmts,
-   const PartialDiagnostic );
 
   // Primary Expressions.
   SourceRange getExprRange(Expr *E) const;

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=359984=359983=359984=diff
==
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Sun May  5 10:10:05 2019
@@ -2089,16 +2089,16 @@ AnalysisBasedWarnings::IssueWarnings(sem
 
 // Register the expressions with the CFGBuilder.
 for (const auto  : fscope->PossiblyUnreachableDiags) {
-  for (const Stmt *S : D.Stmts)
-AC.registerForcedBlockExpression(S);
+  if (D.stmt)
+AC.registerForcedBlockExpression(D.stmt);
 }
 
 if (AC.getCFG()) {
   analyzed = true;
   for (const auto  : fscope->PossiblyUnreachableDiags) {
-bool AllReachable = true;
-for (const Stmt *S : D.Stmts) {
-  const CFGBlock *block = AC.getBlockForRegisteredExpression(S);
+bool processed = false;
+if (D.stmt) {
+  const CFGBlock *block = AC.getBlockForRegisteredExpression(D.stmt);
   CFGReverseBlockReachabilityAnalysis *cra =
   AC.getCFGReachablityAnalysis();
   // FIXME: We should be able to assert that block is non-null, but
@@ -2106,17 +2106,15 @@ AnalysisBasedWarnings::IssueWarnings(sem
   // edge cases; see test/Sema/vla-2.c.
   if (block && cra) {
 // Can this block be reached from the entrance?
-if (!cra->isReachable(()->getEntry(), block)) {
-  AllReachable = false;
-  break;
-}
+if (cra->isReachable(()->getEntry(), block))
+  S.Diag(D.Loc, D.PD);
+processed = true;
   }
-  // If we cannot map to a basic block, assume the statement is
-  // reachable.
 }
-
-if (AllReachable)
+if (!processed) {
+  // Emit the warning anyway if we cannot map to a basic block.
   S.Diag(D.Loc, D.PD);
+}
   }
 }
 

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=359984=359983=359984=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Sun May  5 10:10:05 2019
@@ -12155,11 +12155,10 @@ class SequenceChecker : public Evaluated
 if (OtherKind == UK_Use)
   std::swap(Mod, ModOrUse);
 
-SemaRef.DiagRuntimeBehavior(
-Mod->getExprLoc(), {Mod, ModOrUse},
-

[PATCH] D61509: [PragmaHandler][OpenMP] Expose `#pragma` location

2019-05-05 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D61509#1491204 , @lebedev.ri wrote:

> In D61509#1491158 , @jdenny wrote:
>
> > In D61509#1491119 , @lebedev.ri 
> > wrote:
> >
> > > I recommend to split this into two parts - changing `PragmaIntroducerKind 
> > > Introducer` to
> > >  `struct NameMe { PragmaIntroducerKind Kind; SourceLocation Loc};`, and 
> > > the actual openmp change.
> >
> >
> > Sure, I'll work on that.  What about NameMe = PragmaIntroducer?
>
>
> Could work. And then move `PragmaIntroducerKind` into it.
>  I believe this part of the refactoring is completely uncontroversial.
>
> >> For that change, just basing off the clang-tidy diff, neither variant is 
> >> ideal,
> > 
> > Do you mean that it's better for diagnostics that point to a pragma not to 
> > include the `#pragma` in their locations?  If so, why is that?
>
> I'm not sure either one is better than the other one.
>
> I have two concerns:
>
> - I fear this would result in inconsistency with other pragmas, since this 
> will only change openmp-ones. I don't know if it will be accepted to migrate 
> the rest of them in the same way.
> - This use-case requires having the location of `#pragma`, so the entire AST 
> is migrating to store it. But the current location will no longer be 
> accessible from AST.
>
>   I see two paths forward:
> - Mail cfe-dev, and suggest to do this change for *all* pragmas. Either this 
> is ok for all of them, or none of them.
> - Moar abstractions - how about **not** changing the startloc of openmp 
> directives, but instead add some baseclass to `OMPDirective` class (& every 
> other class that is created from pragma), that would record the 
> `PragmaIntroducer`?
>
> > The other variant I originally proposed doesn't alter existing locations 
> > and so wouldn't affect diagnostics, but Alexey pointed out potential issues 
> > for changes it requires in the parser.
> > 
> >> so i'd like to see the proposed use-case.
> > 
> > That's a bit tricky.  I'll explain.
> > 
> > My use case right now is not for OpenMP locations but for OpenACC locations 
> > in our Clacc project, which is not upstream.  Clacc is calling Rewriter and 
> > passing locations from the OpenACC AST in order to rewrite the OpenACC 
> > pragmas to OpenMP.  Without the location for an OpenACC pragma's `#pragma`, 
> > Clacc cannot easily remove an OpenACC pragma or insert code before it.  At 
> > least not that I found.  Of course, I'd be happy for someone to explain to 
> > me how Rewriter was designed to be used differently.  I'd also be happy to 
> > share relevant code samples from Clacc if that would help.
> > 
> > So what does this have to do with OpenMP locations?  I'm anticipating that 
> > someone will one day want to use Rewriter in this way with other pragmas, 
> > so I'm offering some scaffolding toward that goal for all pragmas, and I'm 
> > completing the fix only for OpenMP, which is the existing pragma set I 
> > understand best.  Moreover, offering this now facilitates keeping Clacc up 
> > to date with master and eventually considering it for upstreaming.
> > 
> > Thanks for your responses.





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

https://reviews.llvm.org/D61509



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


[PATCH] D61509: [PragmaHandler][OpenMP] Expose `#pragma` location

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

In D61509#1491158 , @jdenny wrote:

> In D61509#1491119 , @lebedev.ri 
> wrote:
>
> > I recommend to split this into two parts - changing `PragmaIntroducerKind 
> > Introducer` to
> >  `struct NameMe { PragmaIntroducerKind Kind; SourceLocation Loc};`, and the 
> > actual openmp change.
>
>
> Sure, I'll work on that.  What about NameMe = PragmaIntroducer?


Could work. And then move `PragmaIntroducerKind` into it.
I believe this part of the refactoring is completely uncontroversial.

>> For that change, just basing off the clang-tidy diff, neither variant is 
>> ideal,
> 
> Do you mean that it's better for diagnostics that point to a pragma not to 
> include the `#pragma` in their locations?  If so, why is that?

I'm not sure either one is better than the other one.

I have two concerns:

- I fear this would result in inconsistency with other pragmas, since this will 
only change openmp-ones. I don't know if it will be accepted to migrate the 
rest of them in the same way.
- This use-case requires having the location of `#pragma`, so the entire AST is 
migrating to store it. But the current location will no longer be accessible 
from AST.

I see two paths forward:

- Mail cfe-dev, and suggest to do this change for *all* pragmas. Either this is 
ok for all of them, or none of them.
- Moar abstractions - how about **not** changing the startloc of openmp 
directives, but instead add some baseclass to `OMPDirective` class (& every 
other class that is created from pragma), that would record the 
`PragmaIntroducer`?

> The other variant I originally proposed doesn't alter existing locations and 
> so wouldn't affect diagnostics, but Alexey pointed out potential issues for 
> changes it requires in the parser.
> 
>> so i'd like to see the proposed use-case.
> 
> That's a bit tricky.  I'll explain.
> 
> My use case right now is not for OpenMP locations but for OpenACC locations 
> in our Clacc project, which is not upstream.  Clacc is calling Rewriter and 
> passing locations from the OpenACC AST in order to rewrite the OpenACC 
> pragmas to OpenMP.  Without the location for an OpenACC pragma's `#pragma`, 
> Clacc cannot easily remove an OpenACC pragma or insert code before it.  At 
> least not that I found.  Of course, I'd be happy for someone to explain to me 
> how Rewriter was designed to be used differently.  I'd also be happy to share 
> relevant code samples from Clacc if that would help.
> 
> So what does this have to do with OpenMP locations?  I'm anticipating that 
> someone will one day want to use Rewriter in this way with other pragmas, so 
> I'm offering some scaffolding toward that goal for all pragmas, and I'm 
> completing the fix only for OpenMP, which is the existing pragma set I 
> understand best.  Moreover, offering this now facilitates keeping Clacc up to 
> date with master and eventually considering it for upstreaming.
> 
> Thanks for your responses.




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

https://reviews.llvm.org/D61509



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


[PATCH] D61570: [analyzer] PR41753: Include complex integer types in NonLoc::isCompoundType

2019-05-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, dcoughlin, baloghadamsoftware, xazax.hun, 
rnkovacs, Charusso, a_sidorin.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, gamesh411, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, szepet, whisperity.

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

Caused a crash while fixing another bug, turned out to be easier to fix than 
expected :)


Repository:
  rC Clang

https://reviews.llvm.org/D61570

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  test/Analysis/cxx-uninitialized-object.cpp


Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1167,20 +1167,17 @@
   __complex__ int y;
 };
 
-// FIXME: Currently this causes (unrelated to this checker) an assertion
-// failure.
-//
-//struct ComplexInitTest {
-//  ComplexInitTest() {
-//x = {1.0f, 1.0f};
-//y = {1, 1};
-//  }
-//  __complex__ float x;
-//  __complex__ int y;
-//};
+struct ComplexInitTest {
+  ComplexInitTest() {
+x = {1.0f, 1.0f};
+y = {1, 1};
+  }
+  __complex__ float x;
+  __complex__ int y;
+};
 
 void fComplexTest() {
-//  ComplexInitTest x;
+  ComplexInitTest x;
 
   // TODO: we should emit a warning for x2.x and x2.y.
   ComplexUninitTest x2;
Index: include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -303,7 +303,7 @@
 
   static bool isCompoundType(QualType T) {
 return T->isArrayType() || T->isRecordType() ||
-   T->isComplexType() || T->isVectorType();
+   T->isAnyComplexType() || T->isVectorType();
   }
 
 private:


Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1167,20 +1167,17 @@
   __complex__ int y;
 };
 
-// FIXME: Currently this causes (unrelated to this checker) an assertion
-// failure.
-//
-//struct ComplexInitTest {
-//  ComplexInitTest() {
-//x = {1.0f, 1.0f};
-//y = {1, 1};
-//  }
-//  __complex__ float x;
-//  __complex__ int y;
-//};
+struct ComplexInitTest {
+  ComplexInitTest() {
+x = {1.0f, 1.0f};
+y = {1, 1};
+  }
+  __complex__ float x;
+  __complex__ int y;
+};
 
 void fComplexTest() {
-//  ComplexInitTest x;
+  ComplexInitTest x;
 
   // TODO: we should emit a warning for x2.x and x2.y.
   ComplexUninitTest x2;
Index: include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -303,7 +303,7 @@
 
   static bool isCompoundType(QualType T) {
 return T->isArrayType() || T->isRecordType() ||
-   T->isComplexType() || T->isVectorType();
+   T->isAnyComplexType() || T->isVectorType();
   }
 
 private:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61569: [analyzer][UninitializedObjectChecker] PR41741: Regard all scalar types as primitive.

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

Add a `TODO:`, since we actually don't emit a warning when we should -- I'm 
afraid that this won't be an easy fix though, similarly to ``__vector_size__``: 
D61246#inline-543357 .


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

https://reviews.llvm.org/D61569

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
  test/Analysis/cxx-uninitialized-object.cpp


Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1,11 +1,15 @@
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,optin.cplusplus.UninitializedObject \
+// RUN: %clang_analyze_cc1 -std=c++14 -verify  %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=optin.cplusplus.UninitializedObject \
 // RUN:   -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true 
-DPEDANTIC \
-// RUN:   -analyzer-config 
optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN:   -std=c++14 -verify  %s
+// RUN:   -analyzer-config \
+// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true
 
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,optin.cplusplus.UninitializedObject \
-// RUN:   -analyzer-config 
optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN:   -std=c++14 -verify  %s
+// RUN: %clang_analyze_cc1 -std=c++14 -verify  %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=optin.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config \
+// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true
 
 
//===--===//
 // Default constructor test.
@@ -1156,3 +1160,28 @@
   VectorSizeLong v;
   v.x[0] = 0;
 }
+
+struct ComplexUninitTest {
+  ComplexUninitTest() {}
+  __complex__ float x;
+  __complex__ int y;
+};
+
+// FIXME: Currently this causes (unrelated to this checker) an assertion
+// failure.
+//
+//struct ComplexInitTest {
+//  ComplexInitTest() {
+//x = {1.0f, 1.0f};
+//y = {1, 1};
+//  }
+//  __complex__ float x;
+//  __complex__ int y;
+//};
+
+void fComplexTest() {
+//  ComplexInitTest x;
+
+  // TODO: we should emit a warning for x2.x and x2.y.
+  ComplexUninitTest x2;
+}
Index: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
===
--- lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
+++ lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
@@ -323,9 +323,8 @@
 /// needs to be analyzed as much as checking whether their value is undefined.
 inline bool isPrimitiveType(const QualType ) {
   return T->isBuiltinType() || T->isEnumeralType() ||
- T->isMemberPointerType() || T->isBlockPointerType() ||
  T->isFunctionType() || T->isAtomicType() ||
- T->isVectorType();
+ T->isVectorType() || T->isScalarType();
 }
 
 inline bool isDereferencableType(const QualType ) {


Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1,11 +1,15 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject \
+// RUN: %clang_analyze_cc1 -std=c++14 -verify  %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=optin.cplusplus.UninitializedObject \
 // RUN:   -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
-// RUN:   -analyzer-config optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN:   -std=c++14 -verify  %s
+// RUN:   -analyzer-config \
+// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true
 
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject \
-// RUN:   -analyzer-config optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN:   -std=c++14 -verify  %s
+// RUN: %clang_analyze_cc1 -std=c++14 -verify  %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=optin.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config \
+// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true
 
 //===--===//
 // Default constructor test.
@@ -1156,3 +1160,28 @@
   VectorSizeLong v;
   v.x[0] = 0;
 }
+
+struct ComplexUninitTest {
+  ComplexUninitTest() {}
+  __complex__ float x;
+  __complex__ int y;
+};
+
+// FIXME: Currently this causes (unrelated to this checker) an assertion
+// failure.
+//
+//struct ComplexInitTest {
+//  ComplexInitTest() {
+//x = 

[PATCH] D61569: [analyzer][UninitializedObjectChecker] PR41741: Regard all scalar types as primitive.

2019-05-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, dcoughlin, baloghadamsoftware, gribozavr, 
xazax.hun, rnkovacs, Charusso, a_sidorin.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, gamesh411, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, szepet, whisperity.

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

Pretty much the same as D61246  and D61106 
, this time for `__complex__` types. Upon 
further investigation, I realized that we should regard all types 
`Type::isScalarType` returns true for as primitive, so I merged  
`isMemberPointerType(), `isBlockPointerType()` and `isAnyComplexType()` into 
that instead.

I also stumbled across yet another bug, 
https://bugs.llvm.org/show_bug.cgi?id=41753, but it seems to be unrelated to 
this checker.


Repository:
  rC Clang

https://reviews.llvm.org/D61569

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
  test/Analysis/cxx-uninitialized-object.cpp


Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1,11 +1,15 @@
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,optin.cplusplus.UninitializedObject \
+// RUN: %clang_analyze_cc1 -std=c++14 -verify  %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=optin.cplusplus.UninitializedObject \
 // RUN:   -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true 
-DPEDANTIC \
-// RUN:   -analyzer-config 
optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN:   -std=c++14 -verify  %s
+// RUN:   -analyzer-config \
+// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true
 
-// RUN: %clang_analyze_cc1 
-analyzer-checker=core,optin.cplusplus.UninitializedObject \
-// RUN:   -analyzer-config 
optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN:   -std=c++14 -verify  %s
+// RUN: %clang_analyze_cc1 -std=c++14 -verify  %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=optin.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config \
+// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true
 
 
//===--===//
 // Default constructor test.
@@ -1156,3 +1160,26 @@
   VectorSizeLong v;
   v.x[0] = 0;
 }
+
+struct ComplexUninitTest {
+  ComplexUninitTest() {}
+  __complex__ float x;
+  __complex__ int y;
+};
+
+// FIXME: Currently this causes (unrelated to this checker) an assertion
+// failure.
+//
+//struct ComplexInitTest {
+//  ComplexInitTest() {
+//x = {1.0f, 1.0f};
+//y = {1, 1};
+//  }
+//  __complex__ float x;
+//  __complex__ int y;
+//};
+
+void fComplexTest() {
+//  ComplexInitTest x;
+  ComplexUninitTest x2;
+}
Index: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
===
--- lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
+++ lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
@@ -323,9 +323,8 @@
 /// needs to be analyzed as much as checking whether their value is undefined.
 inline bool isPrimitiveType(const QualType ) {
   return T->isBuiltinType() || T->isEnumeralType() ||
- T->isMemberPointerType() || T->isBlockPointerType() ||
  T->isFunctionType() || T->isAtomicType() ||
- T->isVectorType();
+ T->isVectorType() || T->isScalarType();
 }
 
 inline bool isDereferencableType(const QualType ) {


Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1,11 +1,15 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject \
+// RUN: %clang_analyze_cc1 -std=c++14 -verify  %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=optin.cplusplus.UninitializedObject \
 // RUN:   -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
-// RUN:   -analyzer-config optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN:   -std=c++14 -verify  %s
+// RUN:   -analyzer-config \
+// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true
 
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject \
-// RUN:   -analyzer-config optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN:   -std=c++14 -verify  %s
+// RUN: %clang_analyze_cc1 -std=c++14 -verify  %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=optin.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config \
+// RUN: 

[PATCH] D61509: [PragmaHandler][OpenMP] Expose `#pragma` location

2019-05-05 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In D61509#1491119 , @lebedev.ri wrote:

> I recommend to split this into two parts - changing `PragmaIntroducerKind 
> Introducer` to
>  `struct NameMe { PragmaIntroducerKind Kind; SourceLocation Loc};`, and the 
> actual openmp change.


Sure, I'll work on that.  What about NameMe = PragmaIntroducer?

> For that change, just basing off the clang-tidy diff, neither variant is 
> ideal,

Do you mean that it's better for diagnostics that point to a pragma not to 
include the `#pragma` in their locations?  If so, why is that?

The other variant I originally proposed doesn't alter existing locations and so 
wouldn't affect diagnostics, but Alexey pointed out potential issues for 
changes it requires in the parser.

> so i'd like to see the proposed use-case.

That's a bit tricky.  I'll explain.

My use case right now is not for OpenMP locations but for OpenACC locations in 
our Clacc project, which is not upstream.  Clacc is calling Rewriter and 
passing locations from the OpenACC AST in order to rewrite the OpenACC pragmas 
to OpenMP.  Without the location for an OpenACC pragma's `#pragma`, Clacc 
cannot easily remove an OpenACC pragma or insert code before it.  At least not 
that I found.  Of course, I'd be happy for someone to explain to me how 
Rewriter was designed to be used differently.  I'd also be happy to share 
relevant code samples from Clacc if that would help.

So what does this have to do with OpenMP locations?  I'm anticipating that 
someone will one day want to use Rewriter in this way with other pragmas, so 
I'm offering some scaffolding toward that goal for all pragmas, and I'm 
completing the fix only for OpenMP, which is the existing pragma set I 
understand best.  Moreover, offering this now facilitates keeping Clacc up to 
date with master and eventually considering it for upstreaming.

Thanks for your responses.


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

https://reviews.llvm.org/D61509



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


[PATCH] D61537: [clangd] Boost code completion results that were named in the last few lines.

2019-05-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 198178.
sammccall added a comment.

Further tune numbers based on experiments.
Remove stopwords due to new threshold. Fix tests.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61537

Files:
  clangd/CodeComplete.cpp
  clangd/FindSymbols.cpp
  clangd/Quality.cpp
  clangd/Quality.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/test/completion-auto-trigger.test
  clangd/unittests/CodeCompleteTests.cpp
  clangd/unittests/QualityTests.cpp
  clangd/unittests/SourceCodeTests.cpp

Index: clangd/unittests/SourceCodeTests.cpp
===
--- clangd/unittests/SourceCodeTests.cpp
+++ clangd/unittests/SourceCodeTests.cpp
@@ -22,6 +22,7 @@
 
 using llvm::Failed;
 using llvm::HasValue;
+using testing::UnorderedElementsAreArray;
 
 MATCHER_P2(Pos, Line, Col, "") {
   return arg.line == int(Line) && arg.character == int(Col);
@@ -322,6 +323,19 @@
   EXPECT_EQ(IDs["foo"], 2u);
 }
 
+TEST(SourceCodeTests, CollectWords) {
+  auto Words = collectWords(R"cpp(
+  #define FIZZ_BUZZ
+  // this is a comment
+  std::string getSomeText() { return "magic word"; }
+  )cpp");
+  std::set ActualWords(Words.keys().begin(), Words.keys().end());
+  std::set ExpectedWords = {"define",  "fizz","buzz",  "this",
+ "comment", "string", "some", "text",
+ "return",  "magic",  "word"};
+  EXPECT_EQ(ActualWords, ExpectedWords);
+}
+
 TEST(SourceCodeTests, VisibleNamespaces) {
   std::vector>> Cases = {
   {
Index: clangd/unittests/QualityTests.cpp
===
--- clangd/unittests/QualityTests.cpp
+++ clangd/unittests/QualityTests.cpp
@@ -292,6 +292,16 @@
   SymbolRelevanceSignals InBaseClass;
   InBaseClass.InBaseClass = true;
   EXPECT_LT(InBaseClass.evaluate(), Default.evaluate());
+
+  llvm::StringSet<> Words = {"one", "two", "three"};
+  SymbolRelevanceSignals WithoutMatchingWord;
+  WithoutMatchingWord.ContextWords = 
+  WithoutMatchingWord.Name = "four";
+  EXPECT_EQ(WithoutMatchingWord.evaluate(), Default.evaluate());
+  SymbolRelevanceSignals WithMatchingWord;
+  WithMatchingWord.ContextWords = 
+  WithMatchingWord.Name = "TheTwoTowers";
+  EXPECT_GT(WithMatchingWord.evaluate(), Default.evaluate());
 }
 
 TEST(QualityTests, ScopeProximity) {
Index: clangd/unittests/CodeCompleteTests.cpp
===
--- clangd/unittests/CodeCompleteTests.cpp
+++ clangd/unittests/CodeCompleteTests.cpp
@@ -22,9 +22,11 @@
 #include "index/MemIndex.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/Support/AtomicOrdering.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock-generated-matchers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -174,6 +176,7 @@
   int BBB();
   int CCC();
 };
+
 int main() { ClassWithMembers().^ }
   )cpp",
  /*IndexSymbols=*/{}, Opts);
@@ -324,7 +327,7 @@
   }
 }
 
-TEST(CompletionTest, Priorities) {
+TEST(CompletionTest, Accessible) {
   auto Internal = completions(R"cpp(
   class Foo {
 public: void pub();
@@ -334,7 +337,7 @@
   void Foo::pub() { this->^ }
   )cpp");
   EXPECT_THAT(Internal.Completions,
-  HasSubsequence(Named("priv"), Named("prot"), Named("pub")));
+  AllOf(Has("priv"), Has("prot"), Has("pub")));
 
   auto External = completions(R"cpp(
   class Foo {
@@ -502,6 +505,21 @@
   HasSubsequence(Named("absl"), Named("absb")));
 }
 
+TEST(CompletionTest, ContextWords) {
+  auto Results = completions(R"cpp(
+  enum class Color { RED, YELLOW, BLUE };
+
+  // (blank lines so the definition above isn't "context")
+
+  // "It was a yellow car," he said. "Big yellow car, new."
+  auto Finish = Color::^
+  )cpp");
+  // Yellow would normally sort last (alphabetic).
+  // But the recent mention shuold bump it up.
+  ASSERT_THAT(Results.Completions,
+  HasSubsequence(Named("YELLOW"), Named("BLUE")));
+}
+
 TEST(CompletionTest, GlobalQualified) {
   auto Results = completions(
   R"cpp(
Index: clangd/test/completion-auto-trigger.test
===
--- clangd/test/completion-auto-trigger.test
+++ clangd/test/completion-auto-trigger.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " size",
-# CHECK-NEXT:"sortText": "3eacsize",
+# CHECK-NEXT:"sortText": "{{.*}}size",
 # CHECK-NEXT:"textEdit": {
 # CHECK-NEXT:  "newText": "size",
 # CHECK-NEXT:  "range": {
@@ -45,7 +45,7 @@
 # CHECK-NEXT: "insertTextFormat": 1,
 # 

[PATCH] D61566: Fix for bug 41747: AST Printer doesn't print nested name specifier for out of scope record definitions

2019-05-05 Thread Stepan Dyatkovskiy via Phabricator via cfe-commits
dyatkovskiy created this revision.
dyatkovskiy added a project: clang.
Herald added a subscriber: cfe-commits.

This fix adds out of scope member classes definitions support for AST Printer.


Repository:
  rC Clang

https://reviews.llvm.org/D61566

Files:
  clang/lib/AST/DeclPrinter.cpp
  clang/test/AST/ast-print-record-decl.c


Index: clang/test/AST/ast-print-record-decl.c
===
--- clang/test/AST/ast-print-record-decl.c
+++ clang/test/AST/ast-print-record-decl.c
@@ -287,5 +287,21 @@
   // PRINT-NEXT: };
 };
 
+#ifdef __cplusplus
+// PRINT-CXX-LABEL: outOfRecordDef
+void outOfRecordDef () {
+  // PRINT-CXX-NEXT: struct DeclEnclosing {
+  struct DeclEnclosing {
+// PRINT-CXX-NEXT: struct DeclMember;
+struct DeclMember;
+  // PRINT-CXX-NEXT: };
+  };
+  // PRINT-CXX-NEXT: struct DeclEnclosing::DeclMember {
+  struct DeclEnclosing::DeclMember {
+  // PRINT-CXX-NEXT: };
+  };
+}
+#endif
+
 // A tag decl group in the tag decl's own member list is exercised in
 // defSelfRef above.
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -953,7 +953,12 @@
   prettyPrintAttributes(D);
 
   if (D->getIdentifier()) {
-Out << ' ' << *D;
+Out << ' ';
+
+if (auto *Q = D->getQualifier())
+  Q->print(Out, Policy);
+
+Out << *D;
 
 if (auto S = dyn_cast(D))
   printTemplateArguments(S->getTemplateArgs(), S->getTemplateParameters());


Index: clang/test/AST/ast-print-record-decl.c
===
--- clang/test/AST/ast-print-record-decl.c
+++ clang/test/AST/ast-print-record-decl.c
@@ -287,5 +287,21 @@
   // PRINT-NEXT: };
 };
 
+#ifdef __cplusplus
+// PRINT-CXX-LABEL: outOfRecordDef
+void outOfRecordDef () {
+  // PRINT-CXX-NEXT: struct DeclEnclosing {
+  struct DeclEnclosing {
+// PRINT-CXX-NEXT: struct DeclMember;
+struct DeclMember;
+  // PRINT-CXX-NEXT: };
+  };
+  // PRINT-CXX-NEXT: struct DeclEnclosing::DeclMember {
+  struct DeclEnclosing::DeclMember {
+  // PRINT-CXX-NEXT: };
+  };
+}
+#endif
+
 // A tag decl group in the tag decl's own member list is exercised in
 // defSelfRef above.
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -953,7 +953,12 @@
   prettyPrintAttributes(D);
 
   if (D->getIdentifier()) {
-Out << ' ' << *D;
+Out << ' ';
+
+if (auto *Q = D->getQualifier())
+  Q->print(Out, Policy);
+
+Out << *D;
 
 if (auto S = dyn_cast(D))
   printTemplateArguments(S->getTemplateArgs(), S->getTemplateParameters());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61509: [PragmaHandler][OpenMP] Expose `#pragma` location

2019-05-05 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added reviewers: aaron.ballman, lebedev.ri.
lebedev.ri added a comment.

I recommend to split this into two parts - changing `PragmaIntroducerKind 
Introducer` to
`struct NameMe { PragmaIntroducerKind Kind; SourceLocation Loc};`, and the 
actual openmp change.
For that change, just basing off the clang-tidy diff, neither variant is ideal, 
so i'd like to see the proposed use-case.




Comment at: clang/include/clang/Lex/Pragma.h:68-69
   StringRef getName() const { return Name; }
   virtual void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+SourceLocation IntroducerLoc,
 Token ) = 0;

`PragmaIntroducerKind Introducer` and `SourceLocation IntroducerLoc` are 
talking about the same thing, are they not?
They should be put into some new struct, instead of adding a new parameter.


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

https://reviews.llvm.org/D61509



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


[PATCH] D61552: [clang] Adapt ASTMatcher to explicit(bool) specifier

2019-05-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

You should also regenerate the documentation by running 
clang/docs/tools/dump_ast_matchers.py.




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:1141
 
+/// Matches deduction guide declarations.
+///

Including implicit deduction guides? Might be worth clarifying that.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:6168
 
-/// Matches constructor and conversion declarations that are marked with
-/// the explicit keyword.
+/// Matches constructor, conversion function and deduction guide declarations
+/// that have an explicit specifier if this explicit specifier is resolved to

conversion function and deduction -> conversion function, and deduction



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:6197
 
+/// Matches constructor, conversion function and deduction guide declarations
+/// that have an explicit specifier.

Oxford comma here as well, please.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:6219
+AST_POLYMORPHIC_MATCHER(
+hasExplicitSpecifier,
+AST_POLYMORPHIC_SUPPORTED_TYPES(CXXConstructorDecl, CXXConversionDecl,

I think this is a somewhat useful AST matcher, but I think we are going to need 
a way to match on the expression contained within the explicit specifier too, 
won't we? Perhaps a different approach is to make a matcher named 
`explicitSpecifier()` that allows traversing to the inner expression?



Comment at: clang/lib/ASTMatchers/Dynamic/Registry.cpp:163
   REGISTER_MATCHER(continueStmt);
   REGISTER_MATCHER(cudaKernelCallExpr);
   REGISTER_MATCHER(cxxBindTemporaryExpr);

This is missing the new `hasExplicitSpecifier()` matcher.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61552



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


[PATCH] D61556: [clang] fixing -ast-print for variadic parameter pack in lambda capture

2019-05-05 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added a comment.

You might want to consider getting commit access 
.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61556



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


[PATCH] D61556: [clang] fixing -ast-print for variadic parameter pack in lambda capture

2019-05-05 Thread Nicolas Lesser via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC359980: [clang] fixing -ast-print for variadic parameter 
pack in lambda capture (authored by Rakete, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61556?vs=198155=198172#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61556

Files:
  lib/AST/StmtPrinter.cpp
  test/AST/ast-printer-lambda.cpp


Index: lib/AST/StmtPrinter.cpp
===
--- lib/AST/StmtPrinter.cpp
+++ lib/AST/StmtPrinter.cpp
@@ -1895,6 +1895,9 @@
   llvm_unreachable("VLA type in explicit captures.");
 }
 
+if (C->isPackExpansion())
+  OS << "...";
+
 if (Node->isInitCapture(C))
   PrintExpr(C->getCapturedVar()->getInit());
   }
Index: test/AST/ast-printer-lambda.cpp
===
--- test/AST/ast-printer-lambda.cpp
+++ test/AST/ast-printer-lambda.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -ast-print -std=c++17 %s | FileCheck %s
+
+struct S {
+template
+void test1(int i, T... t) {
+{
+  auto lambda = [i]{};
+  //CHECK: [i] {
+}
+{
+  auto lambda = [=]{};
+  //CHECK: [=] {
+}
+{
+  auto lambda = [&]{};
+  //CHECK: [&] {
+}
+{
+  auto lambda = [t..., i]{};
+  //CHECK: [t..., i] {
+}
+{
+  auto lambda = []{};
+  //CHECK: [] {
+}
+{
+  auto lambda = [this, ]{};
+  //CHECK: [this, ] {
+}
+{
+  auto lambda = [t..., this]{};
+  //CHECK: [t..., this] {
+}
+}
+
+};
\ No newline at end of file


Index: lib/AST/StmtPrinter.cpp
===
--- lib/AST/StmtPrinter.cpp
+++ lib/AST/StmtPrinter.cpp
@@ -1895,6 +1895,9 @@
   llvm_unreachable("VLA type in explicit captures.");
 }
 
+if (C->isPackExpansion())
+  OS << "...";
+
 if (Node->isInitCapture(C))
   PrintExpr(C->getCapturedVar()->getInit());
   }
Index: test/AST/ast-printer-lambda.cpp
===
--- test/AST/ast-printer-lambda.cpp
+++ test/AST/ast-printer-lambda.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -ast-print -std=c++17 %s | FileCheck %s
+
+struct S {
+template
+void test1(int i, T... t) {
+{
+  auto lambda = [i]{};
+  //CHECK: [i] {
+}
+{
+  auto lambda = [=]{};
+  //CHECK: [=] {
+}
+{
+  auto lambda = [&]{};
+  //CHECK: [&] {
+}
+{
+  auto lambda = [t..., i]{};
+  //CHECK: [t..., i] {
+}
+{
+  auto lambda = []{};
+  //CHECK: [] {
+}
+{
+  auto lambda = [this, ]{};
+  //CHECK: [this, ] {
+}
+{
+  auto lambda = [t..., this]{};
+  //CHECK: [t..., this] {
+}
+}
+
+};
\ No newline at end of file
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r359980 - [clang] fixing -ast-print for variadic parameter pack in lambda capture

2019-05-05 Thread Nicolas Lesser via cfe-commits
Author: rakete
Date: Sun May  5 05:35:12 2019
New Revision: 359980

URL: http://llvm.org/viewvc/llvm-project?rev=359980=rev
Log:
[clang] fixing -ast-print for variadic parameter pack in lambda capture

Summary:
currently for:
```
 template
void f(T... t) {
  auto l = [t...]{};
}
```
`clang -ast-print file.cpp`
outputs:

```
template  void f(T ...t) {
auto l = [t] {
}
;
}
```
notice that there is not `...` in the capture list of the lambda. this patch 
fixes this issue. and add test for it.

Patch by Tyker

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/AST/ast-printer-lambda.cpp
Modified:
cfe/trunk/lib/AST/StmtPrinter.cpp

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=359980=359979=359980=diff
==
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Sun May  5 05:35:12 2019
@@ -1895,6 +1895,9 @@ void StmtPrinter::VisitLambdaExpr(Lambda
   llvm_unreachable("VLA type in explicit captures.");
 }
 
+if (C->isPackExpansion())
+  OS << "...";
+
 if (Node->isInitCapture(C))
   PrintExpr(C->getCapturedVar()->getInit());
   }

Added: cfe/trunk/test/AST/ast-printer-lambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-printer-lambda.cpp?rev=359980=auto
==
--- cfe/trunk/test/AST/ast-printer-lambda.cpp (added)
+++ cfe/trunk/test/AST/ast-printer-lambda.cpp Sun May  5 05:35:12 2019
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -ast-print -std=c++17 %s | FileCheck %s
+
+struct S {
+template
+void test1(int i, T... t) {
+{
+  auto lambda = [i]{};
+  //CHECK: [i] {
+}
+{
+  auto lambda = [=]{};
+  //CHECK: [=] {
+}
+{
+  auto lambda = [&]{};
+  //CHECK: [&] {
+}
+{
+  auto lambda = [t..., i]{};
+  //CHECK: [t..., i] {
+}
+{
+  auto lambda = []{};
+  //CHECK: [] {
+}
+{
+  auto lambda = [this, ]{};
+  //CHECK: [this, ] {
+}
+{
+  auto lambda = [t..., this]{};
+  //CHECK: [t..., this] {
+}
+}
+
+};
\ No newline at end of file


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


r359979 - [C++] Interpret unknown identifier in parameter clause as unknown type

2019-05-05 Thread Nicolas Lesser via cfe-commits
Author: rakete
Date: Sun May  5 05:15:17 2019
New Revision: 359979

URL: http://llvm.org/viewvc/llvm-project?rev=359979=rev
Log:
[C++] Interpret unknown identifier in parameter clause as unknown type

instead of as parameter name without a type.

Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/Parser/editor-placeholder-recovery.cpp
cfe/trunk/test/SemaCXX/unknown-type-name.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=359979=359978=359979=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sun May  5 05:15:17 2019
@@ -2649,6 +2649,9 @@ bool Parser::ParseImplicitInt(DeclSpec &
 case tok::semi:
   // This looks like a variable or function declaration. The type is
   // probably missing. We're done parsing decl-specifiers.
+  // But only if we are not in a function prototype scope.
+  if (getCurScope()->isFunctionPrototypeScope())
+break;
   if (SS)
 AnnotateScopeToken(*SS, /*IsNewAnnotation*/false);
   return false;

Modified: cfe/trunk/test/Parser/editor-placeholder-recovery.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/editor-placeholder-recovery.cpp?rev=359979=359978=359979=diff
==
--- cfe/trunk/test/Parser/editor-placeholder-recovery.cpp (original)
+++ cfe/trunk/test/Parser/editor-placeholder-recovery.cpp Sun May  5 05:15:17 
2019
@@ -64,7 +64,7 @@ void avoidPlaceholderErrors(Struct )
 }
 }
 
-void Struct::method(<#Struct #>, noSupressionHere) { // expected-error 
{{unknown type name 'noSupressionHere'}} expected-error {{C++ requires a type 
specifier for all declarations}}
+void Struct::method(<#Struct #>, noSupressionHere) { // expected-error 
{{unknown type name 'noSupressionHere'}}
 #ifndef SUPPRESS
   // expected-error@-2 {{editor placeholder in source file}}
 #endif

Modified: cfe/trunk/test/SemaCXX/unknown-type-name.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/unknown-type-name.cpp?rev=359979=359978=359979=diff
==
--- cfe/trunk/test/SemaCXX/unknown-type-name.cpp (original)
+++ cfe/trunk/test/SemaCXX/unknown-type-name.cpp Sun May  5 05:15:17 2019
@@ -72,9 +72,7 @@ void f(int, T::type x, char) { } // expe
 
 int *p;
 
-// FIXME: We should assume that 'undeclared' is a type, not a parameter name
-//here, and produce an 'unknown type name' diagnostic instead.
-int f1(undeclared, int); // expected-error{{requires a type specifier}}
+int f1(undeclared, int); // expected-error{{unknown type name 'undeclared'}}
 
 int f2(undeclared, 0); // expected-error{{undeclared identifier}}
 


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


[PATCH] D60507: [clang-tidy] new check: bugprone-unhandled-self-assignment

2019-05-05 Thread Tamás Zolnai via Phabricator via cfe-commits
ztamas added a comment.

Ping.
Is it good to go or is there anything else I need to include in this patch?
Among the lots of idea, I'm not sure which is just brainstorming and which is a 
change request.
The check seems to work (has useful catches and does not produce too many false 
positives), however, it does not conform with the corresponding cert rule. I 
expect that a cert alias with an option can be added in a follow-up patch 
(option to ignore ThisHasSuspiciousField pattern). The bugprone-* check would 
have the same default behavior as it has now in this patch. So adding the cert 
alias would not change this behavior, right? In this case, this code change can 
be added in a separate patch I guess.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60507



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


[PATCH] D61556: [clang] fixing -ast-print for variadic parameter pack in lambda capture

2019-05-05 Thread Tyker via Phabricator via cfe-commits
Tyker added a comment.

could you commit it for me please ?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61556



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


[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

2019-05-05 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added a comment.

Is this also okay?

  main.cpp:2:9: warning: lambda expressions are incompatible with C++98 
[-Wc++98-compat]
delete[] { return new int; }
  ^
  main.cpp:2:3: error: '[]' after delete interpreted as 'delete[]'; add 
parentheses to treat this as a lambda-expression
delete[] { return new int; }
^~~~
  ( )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36357



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


[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

2019-05-05 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added a comment.

@rsmith One last question: The fixit diagnostic seems to be inconsistent with 
the rest?

  main.cpp:2:3: error: '[]' after delete interpreted as 'delete[]'
delete[] { return new int; }
^~~~
  ( )

Shouldn't the `^~~` be starting at the `[]`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36357



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


[PATCH] D60552: [X86] Enable intrinsics of AVX512_BF16, which are supported for BFLOAT16 in Cooper Lake

2019-05-05 Thread Tianle Liu via Phabricator via cfe-commits
liutianle updated this revision to Diff 198168.

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

https://reviews.llvm.org/D60552

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/BuiltinsX86.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/avx512bf16intrin.h
  lib/Headers/avx512vlbf16intrin.h
  lib/Headers/cpuid.h
  lib/Headers/immintrin.h
  test/CodeGen/attr-target-x86.c
  test/CodeGen/avx512bf16-builtins.c
  test/CodeGen/avx512vlbf16-builtins.c
  test/Driver/x86-target-features.c
  test/Preprocessor/x86_target_features.c

Index: test/Preprocessor/x86_target_features.c
===
--- test/Preprocessor/x86_target_features.c
+++ test/Preprocessor/x86_target_features.c
@@ -443,3 +443,18 @@
 // RUN: %clang -target i386-unknown-unknown -march=atom -mrdpid -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=RDPID %s
 
 // RDPID: #define __RDPID__ 1
+
+// RUN: %clang -target i386-unknown-unknown -march=atom -mavx512bf16 -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=AVX512BF16 %s
+
+// AVX512BF16: #define __AVX512BF16__ 1
+// AVX512BF16: #define __AVX512BW__ 1
+// AVX512BF16: #define __AVX512VL__ 1
+
+// RUN: %clang -target i386-unknown-unknown -march=atom -mavx512bf16 -mno-avx512bw -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=AVX512BF16_NOAVX512BW %s
+
+// AVX512BF16_NOAVX512BW-NOT: #define __AVX512BF16__ 1
+
+// RUN: %clang -target i386-unknown-unknown -march=atom -mavx512bf16 -mno-avx512vl -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=AVX512BF16_NOAVX512VL %s
+
+// AVX512BF16_NOAVX512VL-NOT: #define __AVX512BF16__ 1
+
Index: test/Driver/x86-target-features.c
===
--- test/Driver/x86-target-features.c
+++ test/Driver/x86-target-features.c
@@ -178,3 +178,8 @@
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-invpcid %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-INVPCID %s
 // INVPCID: "-target-feature" "+invpcid"
 // NO-INVPCID: "-target-feature" "-invpcid"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mavx512bf16 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX512BF16 %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-avx512bf16 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-AVX512BF16 %s
+// AVX512BF16: "-target-feature" "+avx512bf16"
+// NO-AVX512BF16: "-target-feature" "-avx512bf16"
Index: test/CodeGen/avx512vlbf16-builtins.c
===
--- /dev/null
+++ test/CodeGen/avx512vlbf16-builtins.c
@@ -0,0 +1,163 @@
+//  RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin \
+//  RUN:-target-feature +avx512bf16 -target-feature \
+//  RUN:+avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+__m128bh test_mm_cvtne2ps2bf16(__m128 A, __m128 B) {
+  // CHECK-LABEL: @test_mm_cvtne2ps2bf16
+  // CHECK: @llvm.x86.avx512bf16.cvtne2ps2bf16.128
+  // CHECK: ret <8 x i16> %{{.*}}
+  return _mm_cvtne2ps_pbh(A, B);
+}
+
+__m128bh test_mm_maskz_cvtne2ps2bf16(__m128 A, __m128 B, __mmask8 U) {
+  // CHECK-LABEL: @test_mm_maskz_cvtne2ps2bf16
+  // CHECK: @llvm.x86.avx512bf16.cvtne2ps2bf16.128
+  // CHECK: select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+  // CHECK: ret <8 x i16> %{{.*}}
+  return _mm_maskz_cvtne2ps_pbh(U, A, B);
+}
+
+__m128bh test_mm_mask_cvtne2ps2bf16(__m128bh C, __mmask8 U, __m128 A, __m128 B) {
+  // CHECK-LABEL: @test_mm_mask_cvtne2ps2bf16
+  // CHECK: @llvm.x86.avx512bf16.cvtne2ps2bf16.128
+  // CHECK: select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+  // CHECK: ret <8 x i16> %{{.*}}
+  return _mm_mask_cvtne2ps_pbh(C, U, A, B);
+}
+
+__m256bh test_mm256_cvtne2ps2bf16(__m256 A, __m256 B) {
+  // CHECK-LABEL: @test_mm256_cvtne2ps2bf16
+  // CHECK: @llvm.x86.avx512bf16.cvtne2ps2bf16.256
+  // CHECK: ret <16 x i16> %{{.*}}
+  return _mm256_cvtne2ps_pbh(A, B);
+}
+
+__m256bh test_mm256_maskz_cvtne2ps2bf16(__m256 A, __m256 B, __mmask16 U) {
+  // CHECK-LABEL: @test_mm256_maskz_cvtne2ps2bf16
+  // CHECK: @llvm.x86.avx512bf16.cvtne2ps2bf16.256
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+  // CHECK: ret <16 x i16> %{{.*}}
+  return _mm256_maskz_cvtne2ps_pbh(U, A, B);
+}
+
+__m256bh test_mm256_mask_cvtne2ps2bf16(__m256bh C, __mmask16 U, __m256 A, __m256 B) {
+  // CHECK-LABEL: @test_mm256_mask_cvtne2ps2bf16
+  // CHECK: @llvm.x86.avx512bf16.cvtne2ps2bf16.256
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+  // CHECK: ret <16 x i16> %{{.*}}
+  return _mm256_mask_cvtne2ps_pbh(C, U, A, B);
+}
+
+__m512bh test_mm512_cvtne2ps2bf16(__m512 A, __m512 B) {
+  // CHECK-LABEL: @test_mm512_cvtne2ps2bf16
+  // CHECK: 

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

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

Also: https://reviews.llvm.org/D61560


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

https://reviews.llvm.org/D56571



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