[PATCH] D76066: [ARM][MachineOutliner] Add Machine Outliner support for ARM

2020-05-15 Thread Yvan Roux via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0e4827aa4e4a: [ARM][MachineOutliner] Add Machine Outliner 
support for ARM. (authored by yroux).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76066

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
  llvm/lib/Target/ARM/ARMBaseInstrInfo.h
  llvm/lib/Target/ARM/ARMTargetMachine.cpp
  llvm/test/CodeGen/ARM/machine-outliner-tail.ll
  llvm/test/CodeGen/ARM/machine-outliner-thunk.ll
  llvm/test/CodeGen/ARM/machine-outliner-unoutlinable.mir
  llvm/test/CodeGen/ARM/machine-outliner-unsafe-registers.mir

Index: llvm/test/CodeGen/ARM/machine-outliner-unsafe-registers.mir
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/machine-outliner-unsafe-registers.mir
@@ -0,0 +1,114 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=arm-- -run-pass=machine-outliner -verify-machineinstrs \
+# RUN: %s -o - | FileCheck %s
+
+--- |
+  define void @outline_cpsr_r12_ok() #0 { ret void }
+  define void @dont_outline_cpsr_r12_1() #0 { ret void }
+  define void @dont_outline_cpsr_r12_2() #0 { ret void }
+  declare void @z(i32, i32, i32, i32)
+
+  attributes #0 = { minsize optsize }
+...
+---
+
+name:   outline_cpsr_r12_ok
+tracksRegLiveness: true
+body: |
+  ; CHECK-LABEL: name: outline_cpsr_r12_ok
+  ; CHECK: bb.0:
+  ; CHECK:   BL @OUTLINED_FUNCTION_0
+  ; CHECK:   $r3 = MOVr $r12, 14 /* CC::al */, $noreg, $noreg
+  ; CHECK: bb.1:
+  ; CHECK:   BL @OUTLINED_FUNCTION_0
+  ; CHECK:   $r4 = MOVr $r12, 14 /* CC::al */, $noreg, $noreg
+  bb.0:
+$r12 = MOVi 1, 14, $noreg, $noreg
+CMPri $r12, 42, 14, $noreg, implicit-def $cpsr
+$r0 = MOVi 1, 14, $noreg, $noreg
+$r1 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r3 = MOVi 1, 14, $noreg, $noreg
+BL @z
+$r3 = MOVr $r12, 14, $noreg, $noreg
+  bb.1:
+$r12 = MOVi 1, 14, $noreg, $noreg
+CMPri $r12, 42, 14, $noreg, implicit-def $cpsr
+$r0 = MOVi 1, 14, $noreg, $noreg
+$r1 = MOVi 1, 14, $noreg, $noreg
+$r2 = MOVi 1, 14, $noreg, $noreg
+$r3 = MOVi 1, 14, $noreg, $noreg
+BL @z
+$r4 = MOVr $r12, 14, $noreg, $noreg
+  bb.2:
+BX_RET 14, $noreg
+...
+---
+
+name:   dont_outline_cpsr_r12_1
+tracksRegLiveness: true
+body: |
+  ; CHECK-LABEL: name: dont_outline_cpsr_r12_1
+  ; CHECK:  bb.0:
+  ; CHECK:BL @OUTLINED_FUNCTION_1
+  ; CHECK:  bb.1:
+  ; CHECK:BL @OUTLINED_FUNCTION_1
+  ; CHECK-LABEL: bb.2:
+  ; CHECK-NOT: BL @OUTLINED_FUNCTION_1
+  bb.0:
+$r0 = MOVi 2, 14, $noreg, $noreg
+$r1 = MOVi 2, 14, $noreg, $noreg
+$r2 = MOVi 2, 14, $noreg, $noreg
+$r3 = MOVi 2, 14, $noreg, $noreg
+BL @z
+  bb.1:
+$r0 = MOVi 2, 14, $noreg, $noreg
+$r1 = MOVi 2, 14, $noreg, $noreg
+$r2 = MOVi 2, 14, $noreg, $noreg
+$r3 = MOVi 2, 14, $noreg, $noreg
+BL @z
+  bb.2:
+$r12 = MOVi 1, 14, $noreg, $noreg
+CMPri $r12, 42, 14, $noreg, implicit-def $cpsr
+$r0 = MOVi 2, 14, $noreg, $noreg
+$r1 = MOVi 2, 14, $noreg, $noreg
+$r2 = MOVi 2, 14, $noreg, $noreg
+$r3 = MOVi 2, 14, $noreg, $noreg
+BL @z
+  bb.3:
+liveins: $cpsr, $r12
+BX_RET 14, $noreg
+...
+---
+
+name:   dont_outline_cpsr_r12_2
+tracksRegLiveness: true
+body: |
+  ; CHECK-LABEL: name: dont_outline_cpsr_r12_2
+  ; CHECK-NOT: BL @OUTLINED_FUNCTION
+  bb.0:
+liveins: $r12
+CMPri $r12, 42, 14, $noreg, implicit-def $cpsr
+$r0 = MOVi 3, 14, $noreg, $noreg
+$r1 = MOVi 3, 14, $noreg, $noreg
+$r2 = MOVi 3, 14, $noreg, $noreg
+$r3 = MOVi 3, 14, $noreg, $noreg
+BL @z
+  bb.1:
+liveins: $r12
+CMPri $r12, 42, 14, $noreg, implicit-def $cpsr
+$r0 = MOVi 3, 14, $noreg, $noreg
+$r1 = MOVi 3, 14, $noreg, $noreg
+$r2 = MOVi 3, 14, $noreg, $noreg
+$r3 = MOVi 3, 14, $noreg, $noreg
+BL @z
+  bb.2:
+liveins: $r12
+CMPri $r12, 42, 14, $noreg, implicit-def $cpsr
+$r0 = MOVi 3, 14, $noreg, $noreg
+$r1 = MOVi 3, 14, $noreg, $noreg
+$r2 = MOVi 3, 14, $noreg, $noreg
+$r3 = MOVi 3, 14, $noreg, $noreg
+BL @z
+  bb.3:
+BX_RET 14, $noreg
Index: llvm/test/CodeGen/ARM/machine-outliner-unoutlinable.mir
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/machine-outliner-unoutlinable.mir
@@ -0,0 +1,167 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=thumbv7-- -run-pass=machine-outliner -verify-machineinstrs \
+# RUN: %s -o - | FileCheck %s
+
+--- |
+  define void @dont_outline_asm() #0 { ret void }
+  define void @dont_outline_lr() #0 { ret void }
+  define void @dont_outline_lr2() #0 { ret void }
+  define void @dont_outline_it() #0 { ret void }
+  define void @d

[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-05-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

ping @tnorth are you planning on fixing this as its currently reverted.


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326



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


[clang] 854f5f3 - [Sema] Teach -Wcast-align to compute an accurate alignment using the

2020-05-15 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2020-05-15T00:59:03-07:00
New Revision: 854f5f332af4640d9425e9a94442629e4f5a3f98

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

LOG: [Sema] Teach -Wcast-align to compute an accurate alignment using the
alignment information on VarDecls in more cases

This commit improves upon https://reviews.llvm.org/D21099. The code that
computes the source alignment now understands array subscript
expressions, binary operators, derived-to-base casts, and several more
expressions.

rdar://problem/59242343

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

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaCXX/warn-cast-align.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index b4cb76d0b1ad..fbf0fb036fe0 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -30,6 +30,7 @@
 #include "clang/AST/NSAPI.h"
 #include "clang/AST/NonTrivialTypeVisitor.h"
 #include "clang/AST/OperationKinds.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/Type.h"
@@ -13105,17 +13106,226 @@ bool 
Sema::CheckParmsForFunctionDef(ArrayRef Parameters,
   return HasInvalidParm;
 }
 
-/// A helper function to get the alignment of a Decl referred to by DeclRefExpr
-/// or MemberExpr.
-static CharUnits getDeclAlign(Expr *E, CharUnits TypeAlign,
-  ASTContext &Context) {
-  if (const auto *DRE = dyn_cast(E))
-return Context.getDeclAlign(DRE->getDecl());
+Optional>
+static getBaseAlignmentAndOffsetFromPtr(const Expr *E, ASTContext &Ctx);
+
+/// Compute the alignment and offset of the base class object given the
+/// derived-to-base cast expression and the alignment and offset of the derived
+/// class object.
+static std::pair
+getDerivedToBaseAlignmentAndOffset(const CastExpr *CE, QualType DerivedType,
+   CharUnits BaseAlignment, CharUnits Offset,
+   ASTContext &Ctx) {
+  for (auto PathI = CE->path_begin(), PathE = CE->path_end(); PathI != PathE;
+   ++PathI) {
+const CXXBaseSpecifier *Base = *PathI;
+const CXXRecordDecl *BaseDecl = Base->getType()->getAsCXXRecordDecl();
+if (Base->isVirtual()) {
+  // The complete object may have a lower alignment than the non-virtual
+  // alignment of the base, in which case the base may be misaligned. 
Choose
+  // the smaller of the non-virtual alignment and BaseAlignment, which is a
+  // conservative lower bound of the complete object alignment.
+  CharUnits NonVirtualAlignment =
+  Ctx.getASTRecordLayout(BaseDecl).getNonVirtualAlignment();
+  BaseAlignment = std::min(BaseAlignment, NonVirtualAlignment);
+  Offset = CharUnits::Zero();
+} else {
+  const ASTRecordLayout &RL =
+  Ctx.getASTRecordLayout(DerivedType->getAsCXXRecordDecl());
+  Offset += RL.getBaseClassOffset(BaseDecl);
+}
+DerivedType = Base->getType();
+  }
+
+  return std::make_pair(BaseAlignment, Offset);
+}
+
+/// Compute the alignment and offset of a binary additive operator.
+static Optional>
+getAlignmentAndOffsetFromBinAddOrSub(const Expr *PtrE, const Expr *IntE,
+ bool IsSub, ASTContext &Ctx) {
+  QualType PointeeType = PtrE->getType()->getPointeeType();
+
+  if (!PointeeType->isConstantSizeType())
+return llvm::None;
+
+  auto P = getBaseAlignmentAndOffsetFromPtr(PtrE, Ctx);
+
+  if (!P)
+return llvm::None;
 
-  if (const auto *ME = dyn_cast(E))
-return Context.getDeclAlign(ME->getMemberDecl());
+  llvm::APSInt IdxRes;
+  CharUnits EltSize = Ctx.getTypeSizeInChars(PointeeType);
+  if (IntE->isIntegerConstantExpr(IdxRes, Ctx)) {
+CharUnits Offset = EltSize * IdxRes.getExtValue();
+if (IsSub)
+  Offset = -Offset;
+return std::make_pair(P->first, P->second + Offset);
+  }
 
-  return TypeAlign;
+  // If the integer expression isn't a constant expression, compute the lower
+  // bound of the alignment using the alignment and offset of the pointer
+  // expression and the element size.
+  return std::make_pair(
+  P->first.alignmentAtOffset(P->second).alignmentAtOffset(EltSize),
+  CharUnits::Zero());
+}
+
+/// This helper function takes an lvalue expression and returns the alignment 
of
+/// a VarDecl and a constant offset from the VarDecl.
+Optional>
+static getBaseAlignmentAndOffsetFromLValue(const Expr *E, ASTContext &Ctx) {
+  E = E->IgnoreParens();
+  switch (E->getStmtClass()) {
+  default:
+break;
+  case Stmt::CStyleCastExprClass:
+  case Stmt::CXXStaticCastExprClass:
+  case Stmt::ImplicitCastExprClass: {
+auto *CE = cast(E);
+const Expr *

[clang] 170ac4b - [CSInfo][ISEL] Call site info generation support for Mips

2020-05-15 Thread Djordje Todorovic via cfe-commits

Author: Djordje Todorovic
Date: 2020-05-15T10:13:15+02:00
New Revision: 170ac4be3392201d5f5e124e8a1b7d78de3f82c8

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

LOG: [CSInfo][ISEL] Call site info generation support for Mips

Debug entry values functionality provides debug information about
call sites and function parameters values at the call entry spot.
Condition for generating this type of information is
compiling with -g option and optimization level higher
than zero(-O0).

In ISEL phase, while lowering call instructions, collect info
about registers that forward arguments into following
function frame. We store such info into MachineFunction of
the caller function. This is used very late, when dumping DWARF
info about call site parameters.

The call site info is visible at MIR level, as callSites attribute
of MachineFunction. Also, when using unmodified parameter value
inside callee it could be described as DW_OP_entry_value expression.
To deal with callSites attribute, we should pass
-emit-call-site-info option to llc.

This patch enables functionality in clang frontend and adds
call site info generation support for MIPS targets
(mips, mipsel, mips64, mips64el).

Patch by Nikola Tesic

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

Added: 
llvm/test/CodeGen/Mips/call-site-info-output.ll
llvm/test/CodeGen/Mips/dbg-call-site-info-reg-d-split.ll
llvm/test/DebugInfo/Mips/dw_op_entry_value_32bit.ll
llvm/test/DebugInfo/Mips/dw_op_entry_value_64bit.ll

Modified: 
clang/lib/Frontend/CompilerInvocation.cpp
llvm/lib/Target/Mips/MipsISelLowering.cpp
llvm/lib/Target/Mips/MipsTargetMachine.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 7e4bb6ea97e3..2ce71a96c35f 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -783,7 +783,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList 
&Args, InputKind IK,
 
   const llvm::Triple::ArchType DebugEntryValueArchs[] = {
   llvm::Triple::x86, llvm::Triple::x86_64, llvm::Triple::aarch64,
-  llvm::Triple::arm, llvm::Triple::armeb};
+  llvm::Triple::arm, llvm::Triple::armeb, llvm::Triple::mips,
+  llvm::Triple::mipsel, llvm::Triple::mips64, llvm::Triple::mips64el};
 
   llvm::Triple T(TargetOpts.Triple);
   if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&

diff  --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp 
b/llvm/lib/Target/Mips/MipsISelLowering.cpp
index f0b88cd63f4b..3018d8d77c19 100644
--- a/llvm/lib/Target/Mips/MipsISelLowering.cpp
+++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp
@@ -3217,6 +3217,9 @@ 
MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
   // Get a count of how many bytes are to be pushed on the stack.
   unsigned NextStackOffset = CCInfo.getNextStackOffset();
 
+  // Call site info for function parameters tracking.
+  MachineFunction::CallSiteInfo CSInfo;
+
   // Check if it's really possible to do a tail call. Restrict it to functions
   // that are part of this compilation unit.
   bool InternalLinkage = false;
@@ -3343,6 +3346,17 @@ 
MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
 // RegsToPass vector
 if (VA.isRegLoc()) {
   RegsToPass.push_back(std::make_pair(VA.getLocReg(), Arg));
+
+  // If the parameter is passed through reg $D, which splits into
+  // two physical registers, avoid creating call site info.
+  if (Mips::AFGR64RegClass.contains(VA.getLocReg()))
+continue;
+
+  // Collect CSInfo about which register passes which parameter.
+  const TargetOptions &Options = DAG.getTarget().Options;
+  if (Options.SupportsDebugEntryValues)
+CSInfo.emplace_back(VA.getLocReg(), i);
+
   continue;
 }
 
@@ -3447,12 +3461,16 @@ 
MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
 
   if (IsTailCall) {
 MF.getFrameInfo().setHasTailCall();
-return DAG.getNode(MipsISD::TailCall, DL, MVT::Other, Ops);
+SDValue Ret = DAG.getNode(MipsISD::TailCall, DL, MVT::Other, Ops);
+DAG.addCallSiteInfo(Ret.getNode(), std::move(CSInfo));
+return Ret;
   }
 
   Chain = DAG.getNode(MipsISD::JmpLink, DL, NodeTys, Ops);
   SDValue InFlag = Chain.getValue(1);
 
+  DAG.addCallSiteInfo(Chain.getNode(), std::move(CSInfo));
+
   // Create the CALLSEQ_END node in the case of where it is not a call to
   // memcpy.
   if (!(MemcpyInByVal)) {

diff  --git a/llvm/lib/Target/Mips/MipsTargetMachine.cpp 
b/llvm/lib/Target/Mips/MipsTargetMachine.cpp
index 8fec6db00cb9..80cb6ce7ac0c 100644
--- a/llvm/lib/Target/Mips/MipsTargetMachine.cpp
+++ b/llvm/lib/Target/Mips/MipsTargetMachine.cpp
@@ -131,6 +131,9 @@ MipsTargetMachine::Mi

[PATCH] D78105: [CSInfo][ISEL] Call site info generation support for Mips

2020-05-15 Thread Djordje Todorovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG170ac4be3392: [CSInfo][ISEL] Call site info generation 
support for Mips (authored by djtodoro).
Herald added subscribers: cfe-commits, jrtc27.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78105

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/lib/Target/Mips/MipsISelLowering.cpp
  llvm/lib/Target/Mips/MipsTargetMachine.cpp
  llvm/test/CodeGen/Mips/call-site-info-output.ll
  llvm/test/CodeGen/Mips/dbg-call-site-info-reg-d-split.ll
  llvm/test/DebugInfo/Mips/dw_op_entry_value_32bit.ll
  llvm/test/DebugInfo/Mips/dw_op_entry_value_64bit.ll

Index: llvm/test/DebugInfo/Mips/dw_op_entry_value_64bit.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/Mips/dw_op_entry_value_64bit.ll
@@ -0,0 +1,77 @@
+;; Test mips64:
+; RUN: llc -emit-call-site-info -stop-after=livedebugvalues -mtriple=mips64-linux-gnu -o - %s | FileCheck %s --check-prefix=CHECK64
+;; Test mips64el:
+; RUN: llc -emit-call-site-info -stop-after=livedebugvalues -mtriple=mips64el-linux-gnu -o - %s | FileCheck %s --check-prefix=CHECK64el
+
+;; Built from source:
+;; extern long fn1(long,long,long);
+;; long fn2(long a, long b, long c) {
+;;   long local = fn1(a+b, c, b+10);
+;;   if (local > 10)
+;; return local + 10;
+;;   return b;
+;; }
+;; Using command:
+;; clang -g -O2 -target mips64-linux-gnu m.c -c -S -emit-llvm
+;; Confirm that info from callSites attribute is used as entry_value in DIExpression.
+
+;; Test mips64:
+; CHECK64: $a0_64 = nsw DADDu $a1_64, killed renamable $a0_64,
+; CHECK64-NEXT: DBG_VALUE $a0_64, $noreg, !15, !DIExpression(DW_OP_LLVM_entry_value, 1)
+
+;; Test mips64el:
+; CHECK64el: $a0_64 = nsw DADDu $a1_64, killed renamable $a0_64,
+; CHECK64el-NEXT: DBG_VALUE $a0_64, $noreg, !15, !DIExpression(DW_OP_LLVM_entry_value, 1)
+
+; ModuleID = 'm.c'
+source_filename = "m.c"
+target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+target triple = "mips64-unknown-linux-gnu"
+
+; Function Attrs: nounwind
+define i64 @fn2(i64 signext %a, i64 signext %b, i64 signext %c) local_unnamed_addr !dbg !13 {
+entry:
+  call void @llvm.dbg.value(metadata i64 %a, metadata !15, metadata !DIExpression()), !dbg !19
+  call void @llvm.dbg.value(metadata i64 %b, metadata !16, metadata !DIExpression()), !dbg !19
+  call void @llvm.dbg.value(metadata i64 %c, metadata !17, metadata !DIExpression()), !dbg !19
+  %add = add nsw i64 %b, %a, !dbg !19
+  %add1 = add nsw i64 %b, 10, !dbg !19
+  %call = tail call i64 @fn1(i64 signext %add, i64 signext %c, i64 signext %add1), !dbg !19
+  call void @llvm.dbg.value(metadata i64 %call, metadata !18, metadata !DIExpression()), !dbg !19
+  %cmp = icmp sgt i64 %call, 10, !dbg !23
+  %add2 = add nsw i64 %call, 10, !dbg !19
+  %retval.0 = select i1 %cmp, i64 %add2, i64 %b, !dbg !19
+  ret i64 %retval.0, !dbg !19
+}
+
+declare !dbg !4 i64 @fn1(i64 signext, i64 signext, i64 signext) local_unnamed_addr
+
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!8, !9, !10, !11}
+!llvm.ident = !{!12}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "m.c", directory: "/dir")
+!2 = !{}
+!3 = !{!4}
+!4 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
+!5 = !DISubroutineType(types: !6)
+!6 = !{!7, !7, !7, !7}
+!7 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
+!8 = !{i32 7, !"Dwarf Version", i32 4}
+!9 = !{i32 2, !"Debug Info Version", i32 3}
+!10 = !{i32 1, !"wchar_size", i32 4}
+!11 = !{i32 7, !"PIC Level", i32 1}
+!12 = !{!"clang version 11.0.0"}
+!13 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 2, type: !5, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !14)
+!14 = !{!15, !16, !17, !18}
+!15 = !DILocalVariable(name: "a", arg: 1, scope: !13, file: !1, line: 2, type: !7)
+!16 = !DILocalVariable(name: "b", arg: 2, scope: !13, file: !1, line: 2, type: !7)
+!17 = !DILocalVariable(name: "c", arg: 3, scope: !13, file: !1, line: 2, type: !7)
+!18 = !DILocalVariable(name: "local", scope: !13, file: !1, line: 3, type: !7)
+!19 = !DILocation(line: 0, scope: !13)
+!23 = !DILocation(line: 4, column: 13, scope: !24)
+!24 = distinct !DILexicalBlock(scope: !13, file: !1, line: 4, column: 7)
Index: llvm/test/DebugInfo/Mips/dw_op_entry_value_32bit.ll
=

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-15 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG854f5f332af4: [Sema] Teach -Wcast-align to compute an 
accurate alignment using the alignment… (authored by ahatanak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78767

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/warn-cast-align.cpp

Index: clang/test/SemaCXX/warn-cast-align.cpp
===
--- clang/test/SemaCXX/warn-cast-align.cpp
+++ clang/test/SemaCXX/warn-cast-align.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -Wcast-align -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -Wno-unused-value -Wcast-align -verify %s
 
 // Simple casts.
 void test0(char *P) {
@@ -43,3 +43,115 @@
   typedef int *IntPtr;
   c = IntPtr(P);
 }
+
+struct __attribute__((aligned(16))) A {
+  char m0[16];
+  char m1[16];
+};
+
+struct B0 {
+  char m0[16];
+};
+
+struct B1 {
+  char m0[16];
+};
+
+struct C {
+  A &m0;
+  B0 &m1;
+  A m2;
+};
+
+struct __attribute__((aligned(16))) D0 : B0, B1 {
+};
+
+struct __attribute__((aligned(16))) D1 : virtual B0 {
+};
+
+struct B2 {
+  char m0[8];
+};
+
+struct B3 {
+  char m0[8];
+};
+
+struct B4 {
+  char m0[8];
+};
+
+struct D2 : B2, B3 {
+};
+
+struct __attribute__((aligned(16))) D3 : B4, D2 {
+};
+
+struct __attribute__((aligned(16))) D4 : virtual D2 {
+};
+
+struct D5 : virtual D0 {
+  char m0[16];
+};
+
+struct D6 : virtual D5 {
+};
+
+struct D7 : virtual D3 {
+};
+
+void test2(int n, A *a2) {
+  __attribute__((aligned(16))) char m[sizeof(A) * 2];
+  char(&m_ref)[sizeof(A) * 2] = m;
+  extern char(&m_ref_noinit)[sizeof(A) * 2];
+  __attribute__((aligned(16))) char vararray[10][n];
+  A t0;
+  B0 t1;
+  C t2 = {.m0 = t0, .m1 = t1};
+  __attribute__((aligned(16))) char t3[5][5][5];
+  __attribute__((aligned(16))) char t4[4][16];
+  D0 t5;
+  D1 t6;
+  D3 t7;
+  D4 t8;
+  D6 t9;
+  __attribute__((aligned(1))) D7 t10;
+
+  A *a;
+  a = (A *)&m;
+  a = (A *)(m + sizeof(A));
+  a = (A *)(sizeof(A) + m);
+  a = (A *)((sizeof(A) * 2 + m) - sizeof(A));
+  a = (A *)((sizeof(A) * 2 + m) - 1); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(m + 1);   // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(1 + m);   // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(m + n);   // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)&*&m[sizeof(A)];
+  a = (A *)(0, 0, &m[sizeof(A)]);
+  a = (A *)&(0, 0, *&m[sizeof(A)]);
+  a = (A *)&m[n]; // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)&m_ref;
+  a = (A *)&m_ref_noinit;// expected-warning {{cast from 'char (*)[64]' to 'A *'}}
+  a = (A *)(&vararray[4][0]);// expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(a2->m0 + sizeof(A)); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(&t2.m0);
+  a = (A *)(&t2.m1); // expected-warning {{cast from 'B0 *' to 'A *'}}
+  a = (A *)(&t2.m2);
+  a = (A *)(t2.m2.m1);
+  a = (A *)(&t3[3][3][0]); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(&t3[2][2][4]);
+  a = (A *)(&t3[0][n][0]); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)&t4[n][0];
+  a = (A *)&t4[n][1]; // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(t4 + 1);
+  a = (A *)(t4 + n);
+  a = (A *)(static_cast(&t5));
+  a = (A *)(&(static_cast(t5)));
+  a = (A *)(static_cast(&t6)); // expected-warning {{cast from 'B0 *' to 'A *'}}
+  a = (A *)(static_cast(&t7)); // expected-warning {{cast from 'B2 *' to 'A *'}}
+  a = (A *)(static_cast(&t7));
+  a = (A *)(static_cast(&t8));  // expected-warning {{cast from 'B2 *' to 'A *'}}
+  a = (A *)(static_cast(&t8));  // expected-warning {{cast from 'B3 *' to 'A *'}}
+  a = (A *)(static_cast(&t9));  // expected-warning {{cast from 'D5 *' to 'A *'}}
+  a = (A *)(static_cast(&t10)); // expected-warning {{cast from 'D3 *' to 'A *'}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -30,6 +30,7 @@
 #include "clang/AST/NSAPI.h"
 #include "clang/AST/NonTrivialTypeVisitor.h"
 #include "clang/AST/OperationKinds.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/Type.h"
@@ -13105,17 +13106,226 @@
   return HasInvalidParm;
 }
 
-/// A helper function to get the alignment of a Decl referred to by DeclRefExpr
-/// or MemberExpr.
-static CharUnits getDeclAlign(Expr *E, CharUnits TypeAlign,
-  ASTContext &Context) {
-  if (const auto *DRE = dyn_cast(E))
-return Context.getDeclAlign(DRE->getDecl());
+Optional>
+static getBaseAlignmentAndOffsetFromPtr(const Expr *E, ASTContext &Ctx);
+
+

[PATCH] D79921: [OpenMP] Fix omp and clang pragmas

2020-05-15 Thread ISHIGURO, Hiroshi via Phabricator via cfe-commits
hishiguro added a comment.

Thank you for your comments. I will check those comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79921



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


[PATCH] D79330: [Analyzer][VLASizeChecker] Check for VLA size overflow.

2020-05-15 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: clang/test/Analysis/vla-overflow.c:8
+  if (x == BIGINDEX) {
+// We expect here that size_t is a 64 bit value.
+// Size of this array should be the first to overflow.

While it's generally true nowadays, instead of a comment, perhaps turn this 
(`sizeof(size_t) >= 8`) into an assert, or a condition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79330



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


[PATCH] D79322: [FEnv] Small fixes to implementation of flt.rounds

2020-05-15 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 264184.
sepavloff added a comment.

Updated patch

- rebased,
- corrected documentation,
- fixed formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79322

Files:
  clang/include/clang/Basic/Builtins.def
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/RuntimeLibcalls.def
  llvm/lib/CodeGen/IntrinsicLowering.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  llvm/test/CodeGen/MSP430/flt_rounds.ll
  llvm/test/CodeGen/RISCV/flt-rounds.ll

Index: llvm/test/CodeGen/RISCV/flt-rounds.ll
===
--- llvm/test/CodeGen/RISCV/flt-rounds.ll
+++ llvm/test/CodeGen/RISCV/flt-rounds.ll
@@ -9,12 +9,20 @@
 define i32 @test_flt_rounds() nounwind {
 ; RV32I-LABEL: test_flt_rounds:
 ; RV32I:   # %bb.0:
-; RV32I-NEXT:addi a0, zero, 1
+; RV32I-NEXT:addi sp, sp, -16
+; RV32I-NEXT:sw ra, 12(sp)
+; RV32I-NEXT:call __flt_rounds
+; RV32I-NEXT:lw ra, 12(sp)
+; RV32I-NEXT:addi sp, sp, 16
 ; RV32I-NEXT:ret
 ;
 ; RV64I-LABEL: test_flt_rounds:
 ; RV64I:   # %bb.0:
-; RV64I-NEXT:addi a0, zero, 1
+; RV64I-NEXT:addi sp, sp, -16
+; RV64I-NEXT:sd ra, 8(sp)
+; RV64I-NEXT:call __flt_rounds
+; RV64I-NEXT:ld ra, 8(sp)
+; RV64I-NEXT:addi sp, sp, 16
 ; RV64I-NEXT:ret
   %1 = call i32 @llvm.flt.rounds()
   ret i32 %1
Index: llvm/test/CodeGen/MSP430/flt_rounds.ll
===
--- llvm/test/CodeGen/MSP430/flt_rounds.ll
+++ llvm/test/CodeGen/MSP430/flt_rounds.ll
@@ -1,4 +1,4 @@
-; RUN: llc -verify-machineinstrs < %s -march=msp430
+; RUN: llc -verify-machineinstrs -march=msp430 < %s | FileCheck %s
 
 define i16 @foo() {
 entry:
@@ -8,3 +8,5 @@
 }
 
 declare i32 @llvm.flt.rounds() nounwind 
+
+; CHECK: call #__flt_rounds
Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -2814,10 +2814,16 @@
   FA, Offset));
 break;
   }
-  case ISD::FLT_ROUNDS_:
-Results.push_back(DAG.getConstant(1, dl, Node->getValueType(0)));
-Results.push_back(Node->getOperand(0));
+  case ISD::FLT_ROUNDS_: {
+EVT RetVT = Node->getValueType(0);
+TargetLowering::MakeLibCallOptions CallOptions;
+std::pair Tmp =
+TLI.makeLibCall(DAG, RTLIB::FLT_ROUNDS_, RetVT, None, CallOptions,
+SDLoc(Node), Node->getOperand(0));
+Results.push_back(Tmp.first);
+Results.push_back(Tmp.second);
 break;
+  }
   case ISD::EH_RETURN:
   case ISD::EH_LABEL:
   case ISD::PREFETCH:
Index: llvm/lib/CodeGen/IntrinsicLowering.cpp
===
--- llvm/lib/CodeGen/IntrinsicLowering.cpp
+++ llvm/lib/CodeGen/IntrinsicLowering.cpp
@@ -426,10 +426,9 @@
 break;
   }
   case Intrinsic::flt_rounds:
- // Lower to "round to the nearest"
- if (!CI->getType()->isVoidTy())
-   CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1));
- break;
+ReplaceCallWith("__flt_rounds", CI, CI->arg_begin(), CI->arg_end(),
+Type::getInt32Ty(CI->getContext()));
+break;
   case Intrinsic::invariant_start:
   case Intrinsic::lifetime_start:
 // Discard region information.
Index: llvm/include/llvm/IR/RuntimeLibcalls.def
===
--- llvm/include/llvm/IR/RuntimeLibcalls.def
+++ llvm/include/llvm/IR/RuntimeLibcalls.def
@@ -548,6 +548,9 @@
 // Return address
 HANDLE_LIBCALL(RETURN_ADDRESS, nullptr)
 
+// Floating-point Environment
+HANDLE_LIBCALL(FLT_ROUNDS_, "__flt_rounds")
+
 HANDLE_LIBCALL(UNKNOWN_LIBCALL, nullptr)
 
 #undef HANDLE_LIBCALL
Index: llvm/include/llvm/IR/Intrinsics.td
===
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -612,6 +612,14 @@
[IntrNoMem, IntrSpeculatable, IntrWillReturn, ImmArg<1>, ImmArg<2>, ImmArg<3>]>,
GCCBuiltin<"__builtin_object_size">;
 
+//===--- Access to Floating Point Environment -===//
+//
+
+let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn] in {
+  def int_flt_rounds: Intrinsic<[llvm_i32_ty], []>,
+  GCCBuiltin<"__builtin_flt_rounds">;
+}
+
 //===--- Constrained Floating Point Intrinsics ===//
 //
 
@@ -1115,8 +1123,6 @@
 
 ///===-- Other Intrinsics --===//
 //
-def int_flt_rounds : Intrinsic<[llvm_i32_ty]>,
- GCCBuiltin<"__builtin_flt_rounds">;
 def int_trap : Intrinsic<[], [], [IntrNoReturn, IntrCold]>,
   

[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-05-15 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett updated this revision to Diff 264187.
DavidSpickett added a comment.

Update from arc to hopefully run harbormaster builds again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79842

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/program-path-priority.c

Index: clang/test/Driver/program-path-priority.c
===
--- /dev/null
+++ clang/test/Driver/program-path-priority.c
@@ -0,0 +1,115 @@
+// Check the priority used when searching for tools
+// Names and locations are usually in this order:
+// -tool, tool, -tool
+// program path, PATH
+// (from highest to lowest priority)
+// A higher priority name found in a lower priority
+// location will win over a lower priority name in a
+// higher priority location.
+// Prefix dirs (added with -B) override the location,
+// so only name priority is accounted for, unless we fail to find
+// anything at all in the prefix.
+
+// Copy clang to a new dir which will be its
+// "program path" for these tests
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: cp %clang %t
+
+// No gccs at all, nothing is found
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NO_NOTREAL_GCC %s
+// NO_NOTREAL_GCC-NOT: notreal-none-elf-gcc
+// NO_NOTREAL_GCC-NOT: {{/|}}gcc
+
+// -gcc in program path is found
+// RUN: touch %t/notreal-none-elf-gcc
+// RUN: chmod +x %t/notreal-none-elf-gcc
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=PROG_PATH_NOTREAL_GCC %s
+// PROG_PATH_NOTREAL_GCC: notreal-none-elf-gcc
+
+// -gcc on the PATH is found
+// RUN: mkdir -p %t/env
+// RUN: rm %t/notreal-none-elf-gcc
+// RUN: touch %t/env/notreal-none-elf-gcc
+// RUN: chmod +x %t/env/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=ENV_PATH_NOTREAL_GCC %s
+// ENV_PATH_NOTREAL_GCC: env{{/|}}notreal-none-elf-gcc
+
+// -gcc in program path is preferred to one on the PATH
+// RUN: touch %t/notreal-none-elf-gcc
+// RUN: chmod +x %t/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=BOTH_NOTREAL_GCC %s
+// BOTH_NOTREAL_GCC: notreal-none-elf-gcc
+// BOTH_NOTREAL_GCC-NOT: env{{/|}}notreal-none-elf-gcc
+
+// On program path, -gcc is preferred to plain gcc
+// RUN: touch %t/gcc
+// RUN: chmod +x %t/gcc
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOTREAL_GCC_PREFERRED %s
+// NOTREAL_GCC_PREFERRED: notreal-none-elf-gcc
+// NOTREAL_GCC_PREFERRED-NOT: {{/|}}gcc
+
+// -gcc on the PATH is preferred to gcc in program path
+// RUN: rm %t/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PROG %s
+// NOTREAL_PATH_OVER_GCC_PROG: env{{/|}}notreal-none-elf-gcc
+// NOTREAL_PATH_OVER_GCC_PROG-NOT: {{/|}}gcc
+
+// -gcc on the PATH is preferred to gcc on the PATH
+// RUN: rm %t/gcc
+// RUN: touch %t/env/gcc
+// RUN: chmod +x %t/env/gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PATH %s
+// NOTREAL_PATH_OVER_GCC_PATH: env{{/|}}notreal-none-elf-gcc
+// NOTREAL_PATH_OVER_GCC_PATH-NOT: {{/|}}gcc
+
+// -gcc has lowest priority
+// RUN: default_triple=$(%t/clang --version | grep -oP "(?<=Target:\s).*")
+// RUN: touch %t/${default_triple}-gcc
+// RUN: chmod +x %t/${default_triple}-gcc
+
+// -gcc on PATH beats default triple in program path
+// RUN: touch %t/${default_triple}-gcc
+// RUN: chmod +x %t/${default_triple}-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEFAULT_TRIPLE_GCC %s
+// DEFAULT_TRIPLE_GCC: env{{/|}}notreal-none-elf-gcc
+
+// plain gcc on PATH beats default triple in program path
+// RUN: rm %t/env/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEFAULT_TRIPLE_NO_NOTREAL %s
+// DEFAULT_TRIPLE_NO_NOTREAL: env{{/|}}gcc
+// DEFAULT_TRIPLE_NO_NOTREAL-NOT: -gcc
+
+// default triple only chosen when no others are present
+// RUN: rm %t/env/gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEFAULT_TRIPLE_NO_OTHERS %s
+// DEFAULT_TRIPLE_NO_OTHERS: -gcc
+// DEFAULT_TRIPLE_NO_OTHERS-NOT: notreal-none-elf-gcc
+// DEFAULT_TRIPLE_NO_OTHERS-NOT: {{/|}}gcc
+
+// -B paths are searched separately so default triple will win
+// if put in one of those even if other paths have higher priority names
+// RUN: mkdir -p %t/prefix
+// RUN: mv %t/${default_triple}-gcc %t/prefix
+// RUN: touch %t

[PATCH] D79330: [Analyzer][VLASizeChecker] Check for VLA size overflow.

2020-05-15 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

In D79330#2035850 , @balazske wrote:

> I was looking at CERT ARR32-C 
> 
>  "Ensure size arguments for variable length arrays are in a valid range". The 
> VLA should not have a size that is larger than 
> `std::numeric_limits::max()`, in other words "fit into a size_t 
> value", or not?
>
> Yes creating the too large VLA in itself is not a bug, only when `sizeof` is 
> called on it because it can not return the correct size. A non-fatal error is 
> a better option, or delay the check until the sizeof call. But probably the 
> create of such a big array in itself is sign of code smell. The array 
> actually does not need to be created to make the problem happen, only a 
> sizeof call on a typedef-ed and too large VLA. (What does mean that "result 
> of sizeof is implementation-defined"? Probably it can return not the size in 
> bytes or "chars" but something other? In such a case the checker would be not 
> correct.)




In D79330#2036340 , @balazske wrote:

> Is it worth to improve the checker by emitting a warning only if a `sizeof` 
> is used on a `typedef`-ed VLA type where the size is too large (and at a VLA 
> declaration with size overflow)? Or can this be done in a later change?


The result of `sizeof` is implementation-defined because the size of types is 
implementation-defined in the first place (obeying a few other rules). This 
covers the part that the standard does not say that the result value will be 5 
or 7 or 92. The **type** which `sizeof()` returns is a `size_t`, which in 
itself is an implementation-defined type, depending on target architecture). 
This is why the `result of sizeof is implementation-defined`.

However, the following is said about `size_t`:

> std::size_t can store the maximum size of a theoretically possible object of 
> any type (including array). A type whose size cannot be represented by 
> std::size_t is ill-formed (since C++14)

(The first sentence applies for C, too.)

I would reason from this that in case we know there is a type which cannot be 
reasoned about with `sizeof` then this type is bad. This conforms to what 
//ARR32-C// says.
The problem is that if you have an overflown sized array, at the point of 
allocation, the code generated will use this overflown size, which opens the 
door for a plethora of vulnerabilities.

I think we should aim for making the project safe and proper by eliminating bad 
code, instead of hunting //purely// the word of the law. If the intention 
visible in the code can lead to the system blowing up, let's keep the warning 
there where it is easiest to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79330



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


[PATCH] D79862: [clangd-remote] Replace YAML serialization with proper Protobuf messages

2020-05-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 264190.
kbobyrev marked an inline comment as done.
kbobyrev added a comment.
Herald added a subscriber: mgorny.

Add tests for Protobuf (de)serialization.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79862

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestTU.h
  clang-tools-extra/clangd/unittests/remote/CMakeLists.txt
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -0,0 +1,84 @@
+//===--- MarshallingTests.cpp *- 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
+//
+//===--===//
+
+#include "../TestTU.h"
+#include "index/Serialization.h"
+#include "index/remote/marshalling/Marshalling.h"
+#include "llvm/Support/StringSaver.h"
+#include "gtest/gtest.h"
+#include 
+
+namespace clang {
+namespace clangd {
+namespace remote {
+namespace {
+
+class RemoteMarshallingTest : public SymbolCollectorTest {
+public:
+  RemoteMarshallingTest() {
+const std::string Header = R"(
+// This is a class.
+class Foo {
+public:
+  Foo();
+
+  int Bar;
+private:
+  double Number;
+};
+/// This is a function.
+char baz();
+template 
+T getT ();
+struct FooBar {};
+)";
+const std::string Main = R"(
+const int GlobalVariable = 123;
+
+class ForwardDecl;
+char baz() { return 'x'; }
+template 
+T getT() { return T(); }
+Foo::Foo() : Bar(GlobalVariable), Number(42) {
+  for (int Counter = 0; Counter < GlobalVariable; ++Counter) {
+baz();
+getT();
+  }
+}
+)";
+SymbolCollectorTest::runSymbolCollector(Header, Main);
+  }
+};
+
+TEST_F(RemoteMarshallingTest, SymbolSerialization) {
+  llvm::BumpPtrAllocator NewArena;
+  llvm::UniqueStringSaver Strings(NewArena);
+  for (auto &Sym : Symbols) {
+const auto ProtobufMeessage = toProtobuf(Sym);
+const auto SymToProtobufAndBack = fromProtobuf(ProtobufMeessage, &Strings);
+EXPECT_TRUE(SymToProtobufAndBack.hasValue());
+EXPECT_EQ(toYAML(Sym), toYAML(*SymToProtobufAndBack));
+  }
+}
+
+TEST_F(RemoteMarshallingTest, ReferenceSerialization) {
+  llvm::BumpPtrAllocator NewArena;
+  llvm::UniqueStringSaver Strings(NewArena);
+  for (const auto &SymbolWithRefs : Refs) {
+for (const auto &Ref : SymbolWithRefs.second) {
+  const auto RefToProtobufAndBack = fromProtobuf(toProtobuf(Ref), &Strings);
+  EXPECT_TRUE(RefToProtobufAndBack.hasValue());
+  EXPECT_EQ(toYAML(Ref), toYAML(*RefToProtobufAndBack));
+}
+  }
+}
+
+} // namespace
+} // namespace remote
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/remote/CMakeLists.txt
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/remote/CMakeLists.txt
@@ -0,0 +1,26 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
+get_filename_component(CLANGD_SOURCE_DIR
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../clangd REALPATH)
+include_directories(
+  ${CLANGD_SOURCE_DIR}
+  )
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../index/remote)
+add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1)
+
+add_custom_target(ClangdRemoteUnitTests)
+add_unittest(ClangdRemoteUnitTests ClangdRemoteTests
+  MarshallingTests.cpp
+
+  ../TestTU.cpp
+  ../TestFS.cpp
+  )
+
+target_link_libraries(ClangdRemoteTests
+  PRIVATE
+  clangDaemon
+  clangdRemoteMarshalling
+  )
Index: clang-tools-extra/clangd/unittests/TestTU.h
===
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -19,8 +19,13 @@
 
 #include "Compiler.h"
 #include "ParsedAST.h"
+#include "TestFS.h"
 #include "index/Index.h"
+#include "index/SymbolCollector.h"
 #include "support/Path.h"
+#include "clang/Index/IndexingAction.h"
+#include "clang/Index/IndexingOptions.h"
+#include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/StringMap.h"
 #include "gtest/gtest.h"
 #include 
@@ -73,6 +78,47 @@
   std::unique_ptr index() const;
 };
 
+class SymbolIndexActionFactory : public tooling::FrontendActionFactory {
+public:
+  Sym

[PATCH] D79754: [OpenMP][AMDGCN] Support OpenMP offloading for AMDGCN architecture - Part 1

2020-05-15 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 264192.
saiislam added a comment.

Moved isGPU() from llvm's Triple.h to clang's TargetInfo. Renamed it to 
isOpenMPGPU()
to represent target's compatibility with OpenMP offloading and reduce its scope.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79754

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/Decl.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/OpenMP/target_parallel_no_exceptions.cpp
  llvm/include/llvm/ADT/Triple.h

Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -692,6 +692,9 @@
 return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
   }
 
+  /// Tests whether the target is AMDGCN
+  bool isAMDGCN() const { return getArch() == Triple::amdgcn; }
+
   bool isAMDGPU() const {
 return getArch() == Triple::r600 || getArch() == Triple::amdgcn;
   }
Index: clang/test/OpenMP/target_parallel_no_exceptions.cpp
===
--- clang/test/OpenMP/target_parallel_no_exceptions.cpp
+++ clang/test/OpenMP/target_parallel_no_exceptions.cpp
@@ -1,6 +1,7 @@
 /// Make sure no exception messages are inclided in the llvm output.
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHK-EXCEPTION
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHK-EXCEPTION
 
 void test_increment() {
 #pragma omp target
Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -6,6 +6,7 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: powerpc-registered-target
 // REQUIRES: nvptx-registered-target
+// REQUIRES: amdgpu-registered-target
 
 /// ###
 
@@ -249,30 +250,49 @@
 // HAS_DEBUG-SAME: "--return-at-end"
 // HAS_DEBUG: nvlink
 // HAS_DEBUG-SAME: "-g"
+// CUDA_MODE: clang{{.*}}"-cc1"{{.*}}"-triple" "{{nvptx64-nvidia-cuda|amdgcn-amd-amdhsa}}"
+// CUDA_MODE-SAME: "-fopenmp-cuda-mode"
+// NO_CUDA_MODE-NOT: "-{{fno-|f}}openmp-cuda-mode"
 
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fopenmp-cuda-mode 2>&1 \
 // RUN:   | FileCheck -check-prefix=CUDA_MODE %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fno-openmp-cuda-mode -fopenmp-cuda-mode 2>&1 \
 // RUN:   | FileCheck -check-prefix=CUDA_MODE %s
-// CUDA_MODE: clang{{.*}}"-cc1"{{.*}}"-triple" "nvptx64-nvidia-cuda"
-// CUDA_MODE-SAME: "-fopenmp-cuda-mode"
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fno-openmp-cuda-mode 2>&1 \
 // RUN:   | FileCheck -check-prefix=NO_CUDA_MODE %s
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fopenmp-cuda-mode -fno-openmp-cuda-mode 2>&1 \
 // RUN:   | FileCheck -check-prefix=NO_CUDA_MODE %s
-// NO_CUDA_MODE-NOT: "-{{fno-|f}}openmp-cuda-mode"
+
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fopenmp-cuda-mode 2>&1 \
+// RUN:   | FileCheck -check-prefix=CUDA_MODE %s
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fno-openmp-cuda-mode -fopenmp-cuda-mode 2>&1 \
+// RUN:   | FileCheck -check-prefix=CUDA_MODE %s
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fno-openmp-cuda-mode 2>&1 \
+// RUN:   | FileCheck -check-prefix=NO_CUDA_MODE %s
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fopenmp-cuda-mode -fno-openmp-cuda-mode 2>&1 \
+// RUN:   | FileCheck -check-prefix=NO_CUDA_MODE %s
+
+// FULL_RUNTIME: clang{{.*}}"-cc1"{{.*}}"-triple" "{{nvptx64-nvidia-cuda|amdgcn-amd-amdhsa}}"
+// FULL_RUNTIME-SAME: "-fopenmp-cuda-force-full-runtime"
+// NO_FULL_RUNTIME-NOT: "-{{fno-|f}}openmp-cuda-force-

[PATCH] D79693: [test][ARM][CMSE] Use clang_cc1 in arm_cmse.h tests

2020-05-15 Thread Momchil Velikov via Phabricator via cfe-commits
chill accepted this revision.
chill added a comment.
This revision is now accepted and ready to land.

LGTM, thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79693



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


[PATCH] D79990: [clang-format] [PR45614] Incorrectly indents [[nodiscard]] attribute funtions after a macro without semicolon

2020-05-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: krasimir, JakeMerdichAMD, mitchell-stellar, 
owenpan, sylvestre.ledru.
MyDeveloperDay added projects: clang, clang-format.
MyDeveloperDay retitled this revision from "[clang-format] Incorrectly indents 
[[nodiscard]] attribute funtions after a macro without semicolon" to 
"[clang-format] [PR45614] Incorrectly indents [[nodiscard]] attribute funtions 
after a macro without semicolon".
MyDeveloperDay added a reviewer: Abpostelnicu.

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

`[[nodiscard]]` after a macro doesn't behave the same as an __attribute__ 
resulting in incorrect indentation

This revision corrects that behavior

  MACRO
  
  __attribute__((warn_unused_result)) int f3(); // ok
  
  MACRO
  
  [[nodiscard]] int
  f4(); // bad: unexpectedly indented!

See original Mozilla bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=1629756

Before:

  class FooWidget : public nsBaseWidget {
  public:
FooWidget();
  
NS_DECL_ISUPPORTS_INHERITED
  
[[nodiscard]] nsresult
FunctionOne();
[[nodiscard]] nsresult FunctionTwo();
  };

After:

  class FooWidget : public nsBaseWidget {
  public:
FooWidget();
  
NS_DECL_ISUPPORTS_INHERITED
  
[[nodiscard]] nsresult FunctionOne();
[[nodiscard]] nsresult FunctionTwo();
  };




https://reviews.llvm.org/D79990

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7672,6 +7672,37 @@
MultiLineFunctions);
 }
 
+TEST_F(FormatTest, AttributesAfterMacro) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("MACRO;\n"
+   "__attribute__((maybe_unused)) int foo() {\n"
+   "  //...\n"
+   "}");
+
+  verifyFormat("MACRO;\n"
+   "[[nodiscard]] int foo() {\n"
+   "  //...\n"
+   "}");
+
+  EXPECT_EQ("MACRO\n\n"
+"__attribute__((maybe_unused)) int foo() {\n"
+"  //...\n"
+"}",
+format("MACRO\n\n"
+   "__attribute__((maybe_unused)) int foo() {\n"
+   "  //...\n"
+   "}"));
+
+  EXPECT_EQ("MACRO\n\n"
+"[[nodiscard]] int foo() {\n"
+"  //...\n"
+"}",
+format("MACRO\n\n"
+   "[[nodiscard]] int foo() {\n"
+   "  //...\n"
+   "}"));
+}
+
 TEST_F(FormatTest, AttributePenaltyBreaking) {
   FormatStyle Style = getLLVMStyle();
   verifyFormat("void ABCDEFGH::ABCDEFGHIJKLMN(\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -903,30 +903,30 @@
 // Here we blacklist certain tokens that are not usually the first token in an
 // unwrapped line. This is used in attempt to distinguish macro calls without
 // trailing semicolons from other constructs split to several lines.
-static bool tokenCanStartNewLine(const clang::Token &Tok) {
+static bool tokenCanStartNewLine(const FormatToken *Tok) {
   // Semicolon can be a null-statement, l_square can be a start of a macro or
   // a C++11 attribute, but this doesn't seem to be common.
-  return Tok.isNot(tok::semi) && Tok.isNot(tok::l_brace) &&
- Tok.isNot(tok::l_square) &&
+  return Tok->isNot(tok::semi) && Tok->isNot(tok::l_brace) &&
+ Tok->isNot(TT_AttributeSquare) &&
  // Tokens that can only be used as binary operators and a part of
  // overloaded operator names.
- Tok.isNot(tok::period) && Tok.isNot(tok::periodstar) &&
- Tok.isNot(tok::arrow) && Tok.isNot(tok::arrowstar) &&
- Tok.isNot(tok::less) && Tok.isNot(tok::greater) &&
- Tok.isNot(tok::slash) && Tok.isNot(tok::percent) &&
- Tok.isNot(tok::lessless) && Tok.isNot(tok::greatergreater) &&
- Tok.isNot(tok::equal) && Tok.isNot(tok::plusequal) &&
- Tok.isNot(tok::minusequal) && Tok.isNot(tok::starequal) &&
- Tok.isNot(tok::slashequal) && Tok.isNot(tok::percentequal) &&
- Tok.isNot(tok::ampequal) && Tok.isNot(tok::pipeequal) &&
- Tok.isNot(tok::caretequal) && Tok.isNot(tok::greatergreaterequal) &&
- Tok.isNot(tok::lesslessequal) &&
+ Tok->isNot(tok::period) && Tok->isNot(tok::periodstar) &&
+ Tok->isNot(tok::arrow) && Tok->isNot(tok::arrowstar) &&
+ Tok->isNot(tok::less) && Tok->isNot(tok::greater) &&
+ Tok->isNot(tok::slash) && Tok->isNot(tok::percent) &&
+ Tok->isNot(tok::lessless) && Tok->isNot(tok::greatergreater) &&
+ Tok->isNot(tok::equal) && Tok->isNot(tok::plusequal) &&
+ Tok->isNot(tok::minusequal) && Tok->isNot(tok::starequal) &&

[PATCH] D79285: [clang-tidy] Add diagnostics level to YAML output

2020-05-15 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

@alexfh and @gribozavr2 friendly ping could you please take a look


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79285



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


[PATCH] D79990: [clang-format] [PR45614] Incorrectly indents [[nodiscard]] attribute funtions after a macro without semicolon

2020-05-15 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

@MyDeveloperDay thanks for the patch, I'm gonna run it agains mozilla to see if 
there is any fallout.


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

https://reviews.llvm.org/D79990



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


[PATCH] D79673: Allow 32-bit pointer extensions to be used without -fms-extensions

2020-05-15 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki abandoned this revision.
davezarzycki added a comment.

I'm going to abandon this change for now. The problem is that the MS extensions 
are not as pervasive through the language as I wanted. For example, I'd really 
like them to work on aggregate types. This would allow all of the pointers to 
said types to not need annotation, unlike the current MS model.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79673



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


[PATCH] D79992: [WIP][clangd] Patch PP directives to use stale preambles while building ASTs

2020-05-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.
kadircet retitled this revision from "[clangd] Patch PP directives to use stale 
preambles while building ASTs" to "[WIP][clangd] Patch PP directives to use 
stale preambles while building ASTs".

Depends on D79930 .

This enables more accurate parsing of the AST, by making changes in PP
directives in preamble section visible. This is handled by injecting conditional
directives and macro defines/undefs. Note that include insertions are handled
separately in D77644 , to not duplicate 
existing include headers.

This patch doesn't handle any location mappings yet, so features like go-to-def,
go-to-refs and hover might not work as expected. These will be addressed in a
follow-up patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79992

Files:
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp

Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -27,6 +27,7 @@
 #include 
 
 using testing::Field;
+using testing::IsEmpty;
 
 namespace clang {
 namespace clangd {
@@ -181,6 +182,89 @@
   ElementsAre(AllOf(Field(&Inclusion::Written, "\"a.h\""),
 Field(&Inclusion::Resolved, testPath("a.h");
 }
+
+llvm::Optional createPatchedAST(llvm::StringRef Baseline,
+   llvm::StringRef Modified) {
+  auto BaselinePreamble = TestTU::withCode(Baseline).buildPreamble();
+  if (!BaselinePreamble) {
+ADD_FAILURE() << "Failed to build baseline preamble";
+return llvm::None;
+  }
+
+  IgnoreDiagnostics Diags;
+  auto TU = TestTU::withCode(Modified);
+  auto CI = buildCompilerInvocation(TU.inputs(), Diags);
+  if (!CI) {
+ADD_FAILURE() << "Failed to build compiler invocation";
+return llvm::None;
+  }
+  return ParsedAST::build(testPath("main.cpp"), TU.inputs(), std::move(CI), {},
+  BaselinePreamble);
+}
+
+TEST(PreamblePatchTest, Define) {
+  // BAR should be defined while parsing the AST.
+  llvm::StringLiteral Modified(R"cpp(
+#define BAR(X) X
+BAR(int y);
+  )cpp");
+
+  auto AST = createPatchedAST("", Modified);
+  ASSERT_TRUE(AST);
+  EXPECT_THAT(AST->getDiagnostics(), IsEmpty());
+}
+
+TEST(PreamblePatchTest, Undef) {
+  llvm::StringLiteral Baseline = "#define BAR(X) X";
+  // BAR should be undefined while parsing the AST.
+  Annotations Modified(R"cpp(
+#define BAR(X) X
+#undef BAR
+[[BAR]](int y);
+  )cpp");
+
+  auto AST = createPatchedAST(Baseline, Modified.code());
+  ASSERT_TRUE(AST);
+  EXPECT_THAT(AST->getDiagnostics(),
+  ElementsAre(Field(&Diag::Range, Modified.range(;
+}
+
+TEST(PreamblePatchTest, OrderingPreserved) {
+  // Make sure undef goes before define in the patch.
+  llvm::StringLiteral Baseline = "#define BAR(X) X";
+  llvm::StringRef Modified(R"cpp(
+#undef BAR
+#define BAR(X) X
+BAR(int y);
+  )cpp");
+
+  auto AST = createPatchedAST(Baseline, Modified);
+  ASSERT_TRUE(AST);
+  EXPECT_THAT(AST->getDiagnostics(), IsEmpty());
+}
+
+TEST(PreamblePatchTest, SkippedBlocks) {
+  // None of the undef directives should be executed.
+  llvm::StringRef Modified(R"cpp(
+#define BAR(X) X
+#ifdef TEST
+  #undef BAR
+#endif
+#ifndef BAR
+  #undef BAR
+#endif
+#if defined(X) && X
+  #undef BAR
+#elif defined(Y) && Y
+  #undef BAR
+#endif
+BAR(int y);
+  )cpp");
+
+  auto AST = createPatchedAST("", Modified);
+  ASSERT_TRUE(AST);
+  EXPECT_THAT(AST->getDiagnostics(), IsEmpty());
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -15,6 +15,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendActions.h"
@@ -106,14 +107,185 @@
   const SourceManager *SourceMgr = nullptr;
 };
 
-/// Gets the includes in the preamble section of the file by running
-/// preprocessor over \p Contents. Returned includes do not contain resolved
-/// paths. \p VFS and \p Cmd is used to build the compiler invocation, which
-/// might stat/read files.
-llvm::Expected>
-scanPreambleIncludes(llvm::StringRef Contents,
- llvm::IntrusiveRefCntPtr VFS,
-  

[clang-tools-extra] aef778d - [clang-tidy] Fix assertion in RenamerClangTidyChecks

2020-05-15 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-05-15T12:15:35+01:00
New Revision: aef778d4d38e45fd413e7e95919fbb72cde42488

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

LOG: [clang-tidy] Fix assertion in RenamerClangTidyChecks

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
index 56a4c08b7cbc..dd05b3a45c0d 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -207,6 +207,8 @@ class NameLookup {
 /// flag indicating the multiple resolutions.
 NameLookup findDeclInBases(const CXXRecordDecl &Parent, StringRef DeclName,
bool AggressiveTemplateLookup) {
+  if (!Parent.hasDefinition())
+return NameLookup(nullptr);
   if (const NamedDecl *InClassRef = findDecl(Parent, DeclName))
 return NameLookup(InClassRef);
   const NamedDecl *Found = nullptr;



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


[clang] 1a3b801 - [analyzer] SATestBuild.py: Fix handling invalid plists after 2to3 conversion.

2020-05-15 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2020-05-15T14:27:30+03:00
New Revision: 1a3b801db5afe98718b31ba9a760e06557daccb1

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

LOG: [analyzer] SATestBuild.py: Fix handling invalid plists after 2to3 
conversion.

The updated plistlib throws a different exception class.

Added: 


Modified: 
clang/utils/analyzer/SATestBuild.py

Removed: 




diff  --git a/clang/utils/analyzer/SATestBuild.py 
b/clang/utils/analyzer/SATestBuild.py
index 7ca054400716..02eb887500d7 100755
--- a/clang/utils/analyzer/SATestBuild.py
+++ b/clang/utils/analyzer/SATestBuild.py
@@ -58,7 +58,7 @@
 import sys
 import threading
 import time
-from xml.parsers.expat import ExpatError
+
 try:
 import queue
 except ImportError:
@@ -493,7 +493,7 @@ def CleanUpEmptyPlists(SBOutputDir):
 if not Data['files']:
 os.remove(P)
 continue
-except ExpatError as e:
+except plistlib.InvalidFileException as e:
 print('Error parsing plist file %s: %s' % (P, str(e)))
 continue
 



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


[PATCH] D79400: [CMAKE] Fix build failure when source directory is read only

2020-05-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.
Herald added a reviewer: MaskRay.

@scott.linder is actually correct, the reason we write the file is precisely as 
he described in https://reviews.llvm.org/D79400#2021255. When you use tools 
like `repo` which branchless checkout, `.git/logs/HEAD` won't exist on initial 
checkout, but we want to detect changes to it later. It's not true that 
`.git/logs/HEAD` isn't used, see for example in clang/lib/Basic/CMakeLists.txt 
on line 24, while the header is being generated by the 
`GenerateVersionFromVCS.cmake` script, whether that script is executed is 
controlled by a dependency on `.git/logs/HEAD`, if `.git/logs/HEAD` doesn't 
change we won't rerun that script. The reason we do this rather than calling 
`.git/logs/HEAD` directly is to avoid running `git rev-parse HEAD` on every 
build invocation. The reason we depend on ``.git/logs/HEAD` and not `.git/HEAD` 
is because the latter may only contain symbolic information and so won't change 
e.g. on rebase whereas the former will, in which case we want to regenerate the 
header. I agree that the Subversion part of `find_first_existing_vc_file` could 
be removed now. We also don't need to check Clang or LLD source tree separately 
from LLVM now that everything is in one repo, but the logic for determining Git 
revision should be still correct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79400



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


[PATCH] D79400: [CMAKE] Fix build failure when source directory is read only

2020-05-15 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added a comment.

I understand that `.git/logs/HEAD` acts as a dependency for `vcs_revision_h` 
target. However, problem here is that cmake fails when it tries to create 
`.git/logs/HEAD` in read-only filesystem.

I had following ideas for solving above issue,

1. Skip creating `.git/logs/HEAD` whenever a cmake variable (say, 
LLVM_SKIP_VC_HEAD_CHECK) is turned `On`.
2. Remove the creation of `.git/logs/HEAD`.
  - So, in cases of normal checkout, `.git/logs/HEAD` will added as dependency 
to generation script and hence latter will not be triggered for every build.
  - In case of `repo` based checkout, the file will not be created and hence 
will not be a dependency to generation script. In this scenario, script will be 
triggered for every build, but will not generate header if HEAD does not change 
as GenerateVersionFromVCS.cmake#L49 

 will take care.
3. Another way is to gracefully handle the `file` write error, for which I 
don't think there is a portable way. (which @scott.linder also suggested)
4. Last way will be to check if we have write permissions, which again is also 
not portable.

Please suggest if there might exist some other solution. This patch simply 
implements solution number 2.

Also, could you elaborate more on "avoid running `git rev-parse HEAD` for every 
build"? I think it should not harm the build time in such a bad way or maybe I 
am missing something.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79400



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


[PATCH] D79993: Place control block after AST block in PCM files

2020-05-15 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.
dang edited the summary of this revision.

This places the control block after the AST block in PCMs so that the AST block
can be more easily hashed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79993

Files:
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -10,14 +10,12 @@
 //
 //===--===//
 
-#include "clang/AST/OpenMPClause.h"
-#include "clang/Serialization/ASTRecordWriter.h"
 #include "ASTCommon.h"
 #include "ASTReaderInternals.h"
 #include "MultiOnDiskHashTable.h"
-#include "clang/AST/AbstractTypeWriter.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTUnresolvedSet.h"
+#include "clang/AST/AbstractTypeWriter.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
@@ -31,6 +29,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/LambdaCapture.h"
 #include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/OpenMPClause.h"
 #include "clang/AST/RawCommentList.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
@@ -66,6 +65,7 @@
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/Weak.h"
 #include "clang/Serialization/ASTReader.h"
+#include "clang/Serialization/ASTRecordWriter.h"
 #include "clang/Serialization/InMemoryModuleCache.h"
 #include "clang/Serialization/ModuleFile.h"
 #include "clang/Serialization/ModuleFileExtension.h"
@@ -80,6 +80,7 @@
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ScopeExit.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -1138,9 +1139,6 @@
   }
 
   if (WritingModule && WritingModule->Directory) {
-SmallString<128> BaseDir(WritingModule->Directory->getName());
-cleanPathForOutput(Context.getSourceManager().getFileManager(), BaseDir);
-
 // If the home of the module is the current working directory, then we
 // want to pick up the cwd of the build process loading the module, not
 // our cwd, when we load this module.
@@ -1155,14 +1153,8 @@
   unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
 
   RecordData::value_type Record[] = {MODULE_DIRECTORY};
-  Stream.EmitRecordWithBlob(AbbrevCode, Record, BaseDir);
+  Stream.EmitRecordWithBlob(AbbrevCode, Record, BaseDirectory);
 }
-
-// Write out all other paths relative to the base directory if possible.
-BaseDirectory.assign(BaseDir.begin(), BaseDir.end());
-  } else if (!isysroot.empty()) {
-// Write out paths relative to the sysroot if possible.
-BaseDirectory = std::string(isysroot);
   }
 
   // Module map file
@@ -1388,23 +1380,8 @@
   Stream.ExitBlock();
 }
 
-namespace  {
-
-/// An input file.
-struct InputFileEntry {
-  const FileEntry *File;
-  bool IsSystemFile;
-  bool IsTransient;
-  bool BufferOverridden;
-  bool IsTopLevelModuleMap;
-  uint32_t ContentHash[2];
-};
-
-} // namespace
-
 void ASTWriter::WriteInputFiles(SourceManager &SourceMgr,
-HeaderSearchOptions &HSOpts,
-bool Modules) {
+HeaderSearchOptions &HSOpts, bool Modules) {
   using namespace llvm;
 
   Stream.EnterSubblock(INPUT_FILES_BLOCK_ID, 4);
@@ -1428,67 +1405,13 @@
   IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
   unsigned IFHAbbrevCode = Stream.EmitAbbrev(std::move(IFHAbbrev));
 
-  // Get all ContentCache objects for files, sorted by whether the file is a
-  // system one or not. System files go at the back, users files at the front.
-  std::deque SortedFiles;
-  for (unsigned I = 1, N = SourceMgr.local_sloc_entry_size(); I != N; ++I) {
-// Get this source location entry.
-const SrcMgr::SLocEntry *SLoc = &SourceMgr.getLocalSLocEntry(I);
-assert(&SourceMgr.getSLocEntry(FileID::get(I)) == SLoc);
-
-// We only care about file entries that were not overridden.
-if (!SLoc->isFile())
-  continue;
-const SrcMgr::FileInfo &File = SLoc->getFile();
-const SrcMgr::ContentCache *Cache = File.getContentCache();
-if (!Cache->OrigEntry)
-  continue;
-
-InputFileEntry Entry;
-Entry.File = Cache->OrigEntry;
-Entry.IsSystemFile = isSystem(File.getFileCharacteristic());
-Entry.IsTransient = Cache->IsTransient;
-Entry.BufferOverridden = Cache->BufferOverridden;
-Entry.IsTopLevelModuleMap = isModuleMap(File.getFileCharacteristic()) &&
-File.getInclude

[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-05-15 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett updated this revision to Diff 264201.
DavidSpickett added a comment.

Added target triple as a substitution so the tests
don't have to grep for it.
(which I didn't manage to verify on Windows in any case)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79842

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/program-path-priority.c
  clang/test/lit.cfg.py

Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -46,6 +46,8 @@
 config.substitutions.append(
 ('%src_include_dir', config.clang_src_dir + '/include'))
 
+config.substitutions.append(
+('%target_triple', config.target_triple))
 
 # Propagate path to symbolizer for ASan/MSan.
 llvm_config.with_system_environment(
Index: clang/test/Driver/program-path-priority.c
===
--- /dev/null
+++ clang/test/Driver/program-path-priority.c
@@ -0,0 +1,112 @@
+// Check the priority used when searching for tools
+// Names and locations are usually in this order:
+// -tool, tool, -tool
+// program path, PATH
+// (from highest to lowest priority)
+// A higher priority name found in a lower priority
+// location will win over a lower priority name in a
+// higher priority location.
+// Prefix dirs (added with -B) override the location,
+// so only name priority is accounted for, unless we fail to find
+// anything at all in the prefix.
+
+// Copy clang to a new dir which will be its
+// "program path" for these tests
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: cp %clang %t
+
+// No gccs at all, nothing is found
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NO_NOTREAL_GCC %s
+// NO_NOTREAL_GCC-NOT: notreal-none-elf-gcc
+// NO_NOTREAL_GCC-NOT: {{/|}}gcc
+
+// -gcc in program path is found
+// RUN: touch %t/notreal-none-elf-gcc
+// RUN: chmod +x %t/notreal-none-elf-gcc
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=PROG_PATH_NOTREAL_GCC %s
+// PROG_PATH_NOTREAL_GCC: notreal-none-elf-gcc
+
+// -gcc on the PATH is found
+// RUN: mkdir -p %t/env
+// RUN: rm %t/notreal-none-elf-gcc
+// RUN: touch %t/env/notreal-none-elf-gcc
+// RUN: chmod +x %t/env/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=ENV_PATH_NOTREAL_GCC %s
+// ENV_PATH_NOTREAL_GCC: env{{/|}}notreal-none-elf-gcc
+
+// -gcc in program path is preferred to one on the PATH
+// RUN: touch %t/notreal-none-elf-gcc
+// RUN: chmod +x %t/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=BOTH_NOTREAL_GCC %s
+// BOTH_NOTREAL_GCC: notreal-none-elf-gcc
+// BOTH_NOTREAL_GCC-NOT: env{{/|}}notreal-none-elf-gcc
+
+// On program path, -gcc is preferred to plain gcc
+// RUN: touch %t/gcc
+// RUN: chmod +x %t/gcc
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOTREAL_GCC_PREFERRED %s
+// NOTREAL_GCC_PREFERRED: notreal-none-elf-gcc
+// NOTREAL_GCC_PREFERRED-NOT: {{/|}}gcc
+
+// -gcc on the PATH is preferred to gcc in program path
+// RUN: rm %t/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PROG %s
+// NOTREAL_PATH_OVER_GCC_PROG: env{{/|}}notreal-none-elf-gcc
+// NOTREAL_PATH_OVER_GCC_PROG-NOT: {{/|}}gcc
+
+// -gcc on the PATH is preferred to gcc on the PATH
+// RUN: rm %t/gcc
+// RUN: touch %t/env/gcc
+// RUN: chmod +x %t/env/gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PATH %s
+// NOTREAL_PATH_OVER_GCC_PATH: env{{/|}}notreal-none-elf-gcc
+// NOTREAL_PATH_OVER_GCC_PATH-NOT: {{/|}}gcc
+
+// -gcc has lowest priority
+// RUN: touch %t/%target_triple-gcc
+// RUN: chmod +x %t/%target_triple-gcc
+
+// -gcc on PATH beats default triple in program path
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEFAULT_TRIPLE_GCC %s
+// DEFAULT_TRIPLE_GCC: env{{/|}}notreal-none-elf-gcc
+
+// plain gcc on PATH beats default triple in program path
+// RUN: rm %t/env/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEFAULT_TRIPLE_NO_NOTREAL %s
+// DEFAULT_TRIPLE_NO_NOTREAL: env{{/|}}gcc
+// DEFAULT_TRIPLE_NO_NOTREAL-NOT: -gcc
+
+// default triple only chosen when no others are present
+// RUN: rm %t/env/gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEFAULT_TRIPLE_NO_OTHERS %s
+// DEFAULT

[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-05-15 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett marked an inline comment as done.
DavidSpickett added inline comments.



Comment at: clang/test/Driver/program-path-priority.c:72
+// -gcc has lowest priority
+// RUN: default_triple=$(%t/clang --version | grep -oP "(?<=Target:\s).*")
+// RUN: touch %t/${default_triple}-gcc

DavidSpickett wrote:
> Pretty sure I'm stretching the limits here, probably not suitable for 
> Windows. I hoped to be able to capture the default triple in a CHECK line, 
> then use it in a following RUN line. (though thinking about how FileCheck 
> works, that isn't possible)
Resolved by adding a substitution for the default triple.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79842



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


[PATCH] D79322: [FEnv] Small fixes to implementation of flt.rounds

2020-05-15 Thread Sam Elliott via Phabricator via cfe-commits
lenary added inline comments.



Comment at: llvm/test/CodeGen/RISCV/flt-rounds.ll:23
+; RV64I-NEXT:sd ra, 8(sp)
+; RV64I-NEXT:call __flt_rounds
+; RV64I-NEXT:ld ra, 8(sp)

I'm interested to understand how this function is provided. Is it part of 
`compiler-rt` or `libgcc`, or is it provided another way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79322



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


[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

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

Alright, I'm up to speed I think, cheers!

In D79704#2037100 , @NoQ wrote:

> > The code changes make me feel like we're doing a lot of chore (and make it 
> > super easy to forget checking for parameters explicitly).
>
> I wouldn't mind having a common base class for these regions. `DeclRegion` 
> should probably be dropped in this case, in order to avoid dealing with 
> multiple inheritance. And it's definitely the one that needs to be dropped 
> because it currently does nothing except "inheritance for code reuse": there 
> are basically no other common properties between its sub-classes than the 
> accidental code reuse in its methods.


Totally. Something like a `VarRegionBase` but with a more clever name.


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

https://reviews.llvm.org/D79704



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


[PATCH] D79862: [clangd-remote] Replace YAML serialization with proper Protobuf messages

2020-05-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 264205.
kbobyrev added a comment.

Simplify test setup and rebase on top of master.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79862

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestTU.h
  clang-tools-extra/clangd/unittests/remote/CMakeLists.txt
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -0,0 +1,84 @@
+//===--- MarshallingTests.cpp *- 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
+//
+//===--===//
+
+#include "../TestTU.h"
+#include "index/Serialization.h"
+#include "index/remote/marshalling/Marshalling.h"
+#include "llvm/Support/StringSaver.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace remote {
+namespace {
+
+class RemoteMarshallingTest : public SymbolCollectorTest {
+public:
+  RemoteMarshallingTest() : Strings(NewArena) {
+const std::string Header = R"(
+// This is a class.
+class Foo {
+public:
+  Foo();
+
+  int Bar;
+private:
+  double Number;
+};
+/// This is a function.
+char baz();
+template 
+T getT ();
+struct FooBar {};
+)";
+const std::string Main = R"(
+const int GlobalVariable = 123;
+
+class ForwardDecl;
+char baz() { return 'x'; }
+template 
+T getT() { return T(); }
+Foo::Foo() : Bar(GlobalVariable), Number(42) {
+  for (int Counter = 0; Counter < GlobalVariable; ++Counter) {
+baz();
+getT();
+  }
+}
+)";
+SymbolCollectorTest::runSymbolCollector(Header, Main);
+  }
+
+  llvm::UniqueStringSaver Strings;
+
+private:
+  llvm::BumpPtrAllocator NewArena;
+};
+
+TEST_F(RemoteMarshallingTest, SymbolSerialization) {
+  for (auto &Sym : Symbols) {
+const auto ProtobufMeessage = toProtobuf(Sym);
+const auto SymToProtobufAndBack = fromProtobuf(ProtobufMeessage, &Strings);
+EXPECT_TRUE(SymToProtobufAndBack.hasValue());
+EXPECT_EQ(toYAML(Sym), toYAML(*SymToProtobufAndBack));
+  }
+}
+
+TEST_F(RemoteMarshallingTest, ReferenceSerialization) {
+  for (const auto &SymbolWithRefs : Refs) {
+for (const auto &Ref : SymbolWithRefs.second) {
+  const auto RefToProtobufAndBack = fromProtobuf(toProtobuf(Ref), &Strings);
+  EXPECT_TRUE(RefToProtobufAndBack.hasValue());
+  EXPECT_EQ(toYAML(Ref), toYAML(*RefToProtobufAndBack));
+}
+  }
+}
+
+} // namespace
+} // namespace remote
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/remote/CMakeLists.txt
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/remote/CMakeLists.txt
@@ -0,0 +1,26 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
+get_filename_component(CLANGD_SOURCE_DIR
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../clangd REALPATH)
+include_directories(
+  ${CLANGD_SOURCE_DIR}
+  )
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../index/remote)
+add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1)
+
+add_custom_target(ClangdRemoteUnitTests)
+add_unittest(ClangdRemoteUnitTests ClangdRemoteTests
+  MarshallingTests.cpp
+
+  ../TestTU.cpp
+  ../TestFS.cpp
+  )
+
+target_link_libraries(ClangdRemoteTests
+  PRIVATE
+  clangDaemon
+  clangdRemoteMarshalling
+  )
Index: clang-tools-extra/clangd/unittests/TestTU.h
===
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -19,8 +19,13 @@
 
 #include "Compiler.h"
 #include "ParsedAST.h"
+#include "TestFS.h"
 #include "index/Index.h"
+#include "index/SymbolCollector.h"
 #include "support/Path.h"
+#include "clang/Index/IndexingAction.h"
+#include "clang/Index/IndexingOptions.h"
+#include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/StringMap.h"
 #include "gtest/gtest.h"
 #include 
@@ -73,6 +78,47 @@
   std::unique_ptr index() const;
 };
 
+class SymbolIndexActionFactory : public tooling::FrontendActionFactory {
+public:
+  SymbolIndexActionFactory(SymbolCollector::Options COpts,
+   CommentHandler *PragmaHandler)
+  : COpts(std::move(CO

[PATCH] D79325: [clang-format] [PR42164] Add Option to Break before While

2020-05-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay planned changes to this revision.
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added a comment.

let me try that..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79325



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


[PATCH] D79990: [clang-format] [PR45614] Incorrectly indents [[nodiscard]] attribute funtions after a macro without semicolon

2020-05-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D79990#2038207 , @Abpostelnicu 
wrote:

> @MyDeveloperDay thanks for the patch, I'm gonna run it agains mozilla to see 
> if there is any fallout.


I wonder is there a documented way to run clang-format over the gekco sources? 
when I make a change to clang-format I like to run it over some real code not 
just the tests, as I know Mozilla is supposed to be completed formatted this 
might prove to be a better test than running it over LLVM itself (which is alas 
not 100% formatted)


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

https://reviews.llvm.org/D79990



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


[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D79704#2038257 , @Szelethus wrote:

> In D79704#2037100 , @NoQ wrote:
>
> > > The code changes make me feel like we're doing a lot of chore (and make 
> > > it super easy to forget checking for parameters explicitly).
> >
> > I wouldn't mind having a common base class for these regions. `DeclRegion` 
> > should probably be dropped in this case, in order to avoid dealing with 
> > multiple inheritance. And it's definitely the one that needs to be dropped 
> > because it currently does nothing except "inheritance for code reuse": 
> > there are basically no other common properties between its sub-classes than 
> > the accidental code reuse in its methods.
>
>
> Totally. Something like a `VarRegionBase` but with a more clever name.


We can even call it `VarRegion` and have sub-classes be `ParamVarRegion` and 
`NonParamVarRegion` or something like that.


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

https://reviews.llvm.org/D79704



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


[PATCH] D79998: Add AST_SIGNATURE record to unhashed control block of pcm files (Patch series 2/3)

2020-05-15 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

This lets users of PCM get a clean hash of the AST for uniquing based
on that. This required looking up implicit modules in the module offset map to
be looked up by name instead of by file path.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79998

Files:
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/include/clang/Serialization/ModuleFile.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -64,6 +64,7 @@
 #include "clang/Sema/ObjCMethodList.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/Weak.h"
+#include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/ASTRecordWriter.h"
 #include "clang/Serialization/InMemoryModuleCache.h"
@@ -961,6 +962,7 @@
 
   BLOCK(UNHASHED_CONTROL_BLOCK);
   RECORD(SIGNATURE);
+  RECORD(AST_SIGNATURE);
   RECORD(DIAGNOSTIC_OPTIONS);
   RECORD(DIAG_PRAGMA_MAPPINGS);
 
@@ -1045,7 +1047,8 @@
 }
 
 ASTFileSignature ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
-  ASTContext &Context) {
+  ASTContext &Context,
+  StringRef ASTBlockBytes) {
   // Flush first to prepare the PCM hash (signature).
   Stream.FlushToWord();
   auto StartOfUnhashedControl = Stream.GetCurrentBitNo() >> 3;
@@ -1062,6 +1065,10 @@
 Record.append(Signature.begin(), Signature.end());
 Stream.EmitRecord(SIGNATURE, Record);
 Record.clear();
+ASTFileSignature ASTSignature = createSignature(ASTBlockBytes);
+Record.append(ASTSignature.begin(), ASTSignature.end());
+Stream.EmitRecord(AST_SIGNATURE, Record);
+Record.clear();
   }
 
   // Diagnostic options.
@@ -4548,6 +4555,8 @@
   populateInputFileIDs(Context.SourceMgr);
 
   // Write the remaining AST contents.
+  Stream.FlushToWord();
+  auto StartOfASTBlock = Stream.GetCurrentBitNo() >> 3;
   Stream.EnterSubblock(AST_BLOCK_ID, 5);
 
   // This is so that older clang versions, before the introduction
@@ -4679,9 +4688,9 @@
 //   c++-base-specifiers-id:i32
 //   type-id:i32)
 //
-// module-kind is the ModuleKind enum value. If it is MK_PrebuiltModule or
-// MK_ExplicitModule, then the module-name is the module name. Otherwise,
-// it is the module file name.
+// module-kind is the ModuleKind enum value. If it is MK_PrebuiltModule,
+// MK_ExplicitModule or MK_ImplicitModule, then the module-name is the
+// module name. Otherwise, it is the module file name.
 auto Abbrev = std::make_shared();
 Abbrev->Add(BitCodeAbbrevOp(MODULE_OFFSET_MAP));
 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
@@ -4694,10 +4703,11 @@
 
 endian::Writer LE(Out, little);
 LE.write(static_cast(M.Kind));
-StringRef Name =
-  M.Kind == MK_PrebuiltModule || M.Kind == MK_ExplicitModule
-  ? M.ModuleName
-  : M.FileName;
+StringRef Name = M.Kind == MK_PrebuiltModule ||
+ M.Kind == MK_ExplicitModule ||
+ M.Kind == MK_ImplicitModule
+ ? M.ModuleName
+ : M.FileName;
 LE.write(Name.size());
 Out.write(Name.data(), Name.size());
 
@@ -4909,6 +4919,11 @@
   NumStatements, NumMacros, NumLexicalDeclContexts, NumVisibleDeclContexts};
   Stream.EmitRecord(STATISTICS, Record);
   Stream.ExitBlock();
+  Stream.FlushToWord();
+  auto EndOfASTBlock = Stream.GetCurrentBitNo() >> 3;
+
+  StringRef ASTBlockBytes(Buffer.begin() + StartOfASTBlock,
+  EndOfASTBlock - StartOfASTBlock);
 
   // Write the control block
   WriteControlBlock(PP, Context, isysroot, OutputFile);
@@ -4917,7 +4932,7 @@
   for (const auto &ExtWriter : ModuleFileExtensionWriters)
 WriteModuleFileExtension(SemaRef, *ExtWriter);
 
-  return writeUnhashedControlBlock(PP, Context);
+  return writeUnhashedControlBlock(PP, Context, ASTBlockBytes);
 }
 
 void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -3832,17 +3832,18 @@
 
   while (Data < DataEnd) {
 // FIXME: Looking up dependency modules by filename is horrible. Let's
-// start fixing this with prebuilt and explicit modules and see how it
-// goes...
+// start fixing this with prebuilt, expli

[PATCH] D73037: Add a way to set traversal mode in clang-query

2020-05-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D73037#1839391 , @aaron.ballman 
wrote:

> There should also be a mention of this in the release notes (especially if 
> the default behavior winds up changing).


It looks like none of the comments in the review have not been addressed yet. 
Are you planning to make those changes? (Some may no longer be necessary 
because we've made a decision that moots the comment.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73037



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


[PATCH] D72531: Set traversal explicitly where needed in tests

2020-05-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D72531#1845686 , @shafik wrote:

> I was looking at the changes to `ASTImporterTest.cpp` and it not obvious to 
> me how you determined where it was needed.


Some of the changes were reasonably obvious to me because they involved 
matching implicit nodes that require the as-is traversal. However, other 
changes did seem to come from out of nowhere (I commented on one such), and 
hopefully @steveire will explain.




Comment at: clang/unittests/Tooling/StencilTest.cpp:63
   ASTContext &Context = AstUnit->getASTContext();
-  auto Matches = ast_matchers::match(wrapMatcher(Matcher), Context);
+  auto Matches = ast_matchers::match(
+  traverse(ast_type_traits::TK_AsIs, wrapMatcher(Matcher)), Context);

Was this change made because you didn't want to accept the traversal mode as a 
parameter to `matchStmt` and force each caller to decide which mode they use? 
Or is there some other reason why this change was needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72531



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


[PATCH] D79935: [clang-format] [PR44345] Long namespace closing comment is duplicated endlessly

2020-05-15 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:129
+  // } // namespace
+  //   // verylongnamespacenamethatdidnotfitonthepreviouscommenline
+  if (!(Comment->Next && Comment->Next->is(TT_LineComment)))

Nit: typo commenline -> commentline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79935



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


[PATCH] D79862: [clangd-remote] Replace YAML serialization with proper Protobuf messages

2020-05-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/unittests/TestTU.h:1
 //===--- TestTU.h - Scratch source files for testing -*- 
C++-*-===//
 //

This header provides a widely used abstraction and has a clear scope, please 
don't dump things here.



Comment at: clang-tools-extra/clangd/unittests/TestTU.h:94
+
+class SymbolCollectorTest : public ::testing::Test {
+public:

I don't think the API of this class has been thought through well enough to 
share.

Why do you need it? Can't you just use TestTU::headerSymbols() (if you need 
Refs and such as well, just copy its implementation - it's 2 lines long)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79862



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


[PATCH] D80001: [RFC/WIP][clang] Fix printing of names of inherited constructors

2020-05-15 Thread Pavel Labath via Phabricator via cfe-commits
labath created this revision.
labath added reviewers: rsmith, dblaikie.
Herald added a subscriber: aprantl.
Herald added a project: clang.

This is a fairly hacky fix to the following problem: Debug information
entries for inherited constructors are emitted with the name of the base
class, instead of the inheriting class.

This problem can be tracked down to a FIXME in
Sema::findInheritingConstructor, which works around the problem of not
having a DeclarationName to describe inherited constructors. The current
patch compounds that workaround by printing the inherited constructor
name in a different way.

I don't really expect this patch to make its way into the tree in the
current form. I am mainly putting it up to point out the problem and
start a discussion on the solution. I suppose the right fix is to
implement the FIXME, and add a new DeclarationName kind. But that seems
like it could be a fairly involved change, so I wanted to get some
confirmation (and maybe a bit of guidance) first.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80001

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/test/CodeGenCXX/debug-info-inheriting-constructor.cpp
  clang/test/CodeGenCXX/debug-info-inlined.cpp


Index: clang/test/CodeGenCXX/debug-info-inlined.cpp
===
--- clang/test/CodeGenCXX/debug-info-inlined.cpp
+++ clang/test/CodeGenCXX/debug-info-inlined.cpp
@@ -26,4 +26,4 @@
 // CHECK-SAME: !dbg ![[INL:[0-9]+]]
 
 // CHECK: ![[INL]] = !DILocation(line: 10, scope: ![[SP:[0-9]+]], inlinedAt:
-// CHECK: ![[SP]] = distinct !DISubprogram(name: "Base", {{.*}} 
DISPFlagDefinition
+// CHECK: ![[SP]] = distinct !DISubprogram(name: "Forward", {{.*}} 
DISPFlagDefinition
Index: clang/test/CodeGenCXX/debug-info-inheriting-constructor.cpp
===
--- clang/test/CodeGenCXX/debug-info-inheriting-constructor.cpp
+++ clang/test/CodeGenCXX/debug-info-inheriting-constructor.cpp
@@ -16,10 +16,10 @@
 // CHECK-SAME: metadata ![[THIS:[0-9]+]], metadata !DIExpression()), !dbg 
![[LOC:[0-9]+]]
 // CHECK: ret void, !dbg ![[NOINL:[0-9]+]]
 // CHECK: ![[FOO:.*]] = distinct !DISubprogram(name: "foo"
-// CHECK-DAG: ![[A:.*]] = distinct !DISubprogram(name: "A", linkageName: 
"_ZN1BCI11AEiz"
+// CHECK-DAG: ![[B:.*]] = distinct !DISubprogram(name: "B", linkageName: 
"_ZN1BCI11AEiz"
 void foo() {
-// CHECK-DAG: ![[LOC]] = !DILocation(line: 0, scope: ![[A]], inlinedAt: 
![[INL:[0-9]+]])
-// CHECK-DAG: ![[INL]] = !DILocation(line: [[@LINE+1]], scope: ![[FOO]])
+  // CHECK-DAG: ![[LOC]] = !DILocation(line: 0, scope: ![[B]], inlinedAt: 
![[INL:[0-9]+]])
+  // CHECK-DAG: ![[INL]] = !DILocation(line: [[@LINE+1]], scope: ![[FOO]])
   B b(0);
 // CHECK: ![[NOINL]] = !DILocation(line: [[@LINE+1]], scope: !{{[0-9]+}})
 }
Index: clang/include/clang/AST/DeclCXX.h
===
--- clang/include/clang/AST/DeclCXX.h
+++ clang/include/clang/AST/DeclCXX.h
@@ -2631,6 +2631,13 @@
 return const_cast(this)->getCanonicalDecl();
   }
 
+  void printName(raw_ostream &os) const override {
+if (isInheritingConstructor())
+  getParent()->printName(os);
+else
+  CXXMethodDecl::printName(os);
+  }
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == CXXConstructor; }


Index: clang/test/CodeGenCXX/debug-info-inlined.cpp
===
--- clang/test/CodeGenCXX/debug-info-inlined.cpp
+++ clang/test/CodeGenCXX/debug-info-inlined.cpp
@@ -26,4 +26,4 @@
 // CHECK-SAME: !dbg ![[INL:[0-9]+]]
 
 // CHECK: ![[INL]] = !DILocation(line: 10, scope: ![[SP:[0-9]+]], inlinedAt:
-// CHECK: ![[SP]] = distinct !DISubprogram(name: "Base", {{.*}} DISPFlagDefinition
+// CHECK: ![[SP]] = distinct !DISubprogram(name: "Forward", {{.*}} DISPFlagDefinition
Index: clang/test/CodeGenCXX/debug-info-inheriting-constructor.cpp
===
--- clang/test/CodeGenCXX/debug-info-inheriting-constructor.cpp
+++ clang/test/CodeGenCXX/debug-info-inheriting-constructor.cpp
@@ -16,10 +16,10 @@
 // CHECK-SAME: metadata ![[THIS:[0-9]+]], metadata !DIExpression()), !dbg ![[LOC:[0-9]+]]
 // CHECK: ret void, !dbg ![[NOINL:[0-9]+]]
 // CHECK: ![[FOO:.*]] = distinct !DISubprogram(name: "foo"
-// CHECK-DAG: ![[A:.*]] = distinct !DISubprogram(name: "A", linkageName: "_ZN1BCI11AEiz"
+// CHECK-DAG: ![[B:.*]] = distinct !DISubprogram(name: "B", linkageName: "_ZN1BCI11AEiz"
 void foo() {
-// CHECK-DAG: ![[LOC]] = !DILocation(line: 0, scope: ![[A]], inlinedAt: ![[INL:[0-9]+]])
-// CHECK-DAG: ![[INL]] = !DILocation(line: [[@LINE+1]], scope: ![[FOO]])
+  // CHECK-DAG: ![[LOC]] = !DILocation(line: 0, scope: ![[B]], inlinedAt: ![[INL:[0-9]+]])
+  // CHECK-DAG: ![[INL]] = !DILocation(line: [[@LINE+1]], scope

[clang] 8fa743a - [clang-format] C# property formatting can be controlled by config options

2020-05-15 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-05-15T14:08:40+01:00
New Revision: 8fa743ab82027da443bac050e86b70bcdb78cbee

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

LOG: [clang-format] C# property formatting can be controlled by config options

Summary:
Allow brace wrapping in C# property accessors to be controlled by configuration 
options.

Add new tests and revert old test results for Microsoft style to their previous 
state (as intended).

`FormatStyle.BraceWrapping.AfterFunction = true;` will change automatic 
property formatting from

```
Type MyType { get; set }
```

to

```
Type MyType
{ get; set }
```

Reviewers: krasimir, MyDeveloperDay

Reviewed By: krasimir, MyDeveloperDay

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index b303758f1cb8..58206a06ea1a 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1531,6 +1531,8 @@ bool UnwrappedLineParser::tryToParsePropertyAccessor() {
   // Try to parse the property accessor:
   // 
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
   Tokens->setPosition(StoredPosition);
+  if (Style.BraceWrapping.AfterFunction == true)
+addUnwrappedLine();
   nextToken();
   do {
 switch (FormatTok->Tok.getKind()) {

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index 6f0b1966767d..5567e19e5bdd 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -245,11 +245,13 @@ TEST_F(FormatTestCSharp, Attributes) {
"}");
 
   verifyFormat("[TestMethod]\n"
-   "public string Host { set; get; }");
+   "public string Host\n"
+   "{ set; get; }");
 
   verifyFormat("[TestMethod(\"start\", HelpText = \"Starts the server "
"listening on provided host\")]\n"
-   "public string Host { set; get; }");
+   "public string Host\n"
+   "{ set; get; }");
 
   verifyFormat(
   "[DllImport(\"Hello\", EntryPoint = \"hello_world\")]\n"
@@ -675,6 +677,32 @@ class MyClass {
 set => veryLongNamedField = value;
   } = VeryLongNamedTypeIndeed.Create(DefaultFirstArgument, 
DefaultSecondArgument,
  DefaultThirdArgument);
+})",
+   Style);
+
+  // Brace wrapping and single-lining of accessor can be controlled by config.
+  Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterFunction = true;
+
+  verifyFormat(R"(//
+public class SaleItem {
+  public decimal Price
+  { get; set; }
+})",
+   Style);
+
+  verifyFormat(R"(//
+class TimePeriod {
+  public double Hours
+  {
+get {
+  return _seconds / 3600;
+}
+set {
+  _seconds = value * 3600;
+}
+  }
 })",
Style);
 }



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


[PATCH] D79998: Add AST_SIGNATURE record to unhashed control block of pcm files (Patch series 2/3)

2020-05-15 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added a comment.

Should I add the test here or in the clang-scan-deps patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79998



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


[PATCH] D72532: Make the ExprMutationAnalyzer explicit about how it traverses the AST

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

LGTM, assuming that this causes existing tests cover the changes so we don't 
need new tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72532



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


[PATCH] D79000: [clang-format] C# property formatting can be controlled by config options

2020-05-15 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe closed this revision.
jbcoe added a comment.

Submitted as 8fa743ab82027da443bac050e86b70bcdb78cbee 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79000



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


[PATCH] D80003: [clang][clang-scan-deps] Add a mode that can compute overhead in duplicated module builds

2020-05-15 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: cfe-commits, tschuett, dexonsmith.
Herald added a project: clang.

Adds a command line option "--metrics" that computes and outputs this
information at the end of a run.
This identifies modules duplicated due to strict context hashing and computes
how many of them of identical ASTs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80003

Files:
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -6,12 +6,14 @@
 //
 //===--===//
 
+#include "clang/Basic/Module.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/InitLLVM.h"
@@ -20,6 +22,7 @@
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 
@@ -165,6 +168,13 @@
 llvm::cl::init(false),
 llvm::cl::cat(DependencyScannerCategory));
 
+llvm::cl::opt GatherMetrics(
+"metrics", llvm::cl::Optional,
+llvm::cl::desc(
+"Gather metrics during tool operation to measure overhead of modules "
+"built in explicit mode with respect to implicit modules."),
+llvm::cl::init(false), llvm::cl::cat(DependencyScannerCategory));
+
 } // end anonymous namespace
 
 /// \returns object-file path derived from source-file path.
@@ -327,6 +337,65 @@
 OS << llvm::formatv("{0:2}\n", Value(std::move(Output)));
   }
 
+  void computeAndPrintBuildMetrics(raw_ostream &OS) {
+std::unordered_map
+RelaxedHashesEfficiencyInfo;
+std::set UniqueModuleSignatures;
+for (auto &&M : Modules) {
+  std::string RelaxedHashModule =
+  M.second.ModuleName + '-' + M.second.RelaxedContextHash;
+  auto &BuiltModulesInfo = RelaxedHashesEfficiencyInfo[RelaxedHashModule];
+  BuiltModulesInfo.BuiltModules.push_back(&M.second);
+  auto InsertionResult =
+  UniqueModuleSignatures.insert(M.second.ModuleSignature);
+  if (InsertionResult.second)
+BuiltModulesInfo.UniqueASTFileSignatures++;
+}
+
+size_t TotalStrictContextHashModules = Modules.size();
+size_t TotalRelaxedHashModules = RelaxedHashesEfficiencyInfo.size();
+auto PercentageModuleNumberIncrease =
+100 * ((TotalStrictContextHashModules - TotalRelaxedHashModules) /
+   TotalRelaxedHashModules);
+
+OS << "Total relaxed hash modules: " << TotalRelaxedHashModules << "\n";
+OS << "Total unique AST signatures: " << UniqueModuleSignatures.size()
+   << "\n";
+OS << "Total strict context hash modules: " << TotalStrictContextHashModules
+   << "\n";
+OS << "Module number increase: " << PercentageModuleNumberIncrease
+   << "%\n\n";
+
+OS << "Details:\n";
+for (auto &&It : RelaxedHashesEfficiencyInfo) {
+  auto &Duplicates = It.second.BuiltModules;
+  size_t NumDuplicates = Duplicates.size();
+
+  assert(NumDuplicates > 0 && "Cannot have a relaxed hash module that "
+  "doesn't map to at least a strict"
+  "one!");
+
+  if (NumDuplicates > 1) {
+OS << "Relaxed hash module: " << It.first << " gets duplicated as ("
+   << It.second.UniqueASTFileSignatures << "/" << NumDuplicates
+   << ") modules:\n\n";
+
+auto OutputModuleDep = [](raw_ostream &OS, ModuleDeps *MD) {
+  OS << MD->ModuleName << "-" << MD->ContextHash;
+};
+
+auto DuplicatesIt = Duplicates.begin();
+OutputModuleDep(OS, *DuplicatesIt);
+++DuplicatesIt;
+for (auto End = Duplicates.end(); DuplicatesIt != End; ++DuplicatesIt) {
+  OS << "; ";
+  OutputModuleDep(OS, *DuplicatesIt);
+}
+OS << "\n\n";
+  }
+}
+  }
+
 private:
   StringRef lookupPCMPath(ClangModuleDep CMD) {
 return Modules[ContextModulePair{CMD.ContextHash, CMD.ModuleName, 0}]
@@ -340,6 +409,11 @@
 return I->second;
   };
 
+  struct BuiltModulesEfficien

[PATCH] D79990: [clang-format] [PR45614] Incorrectly indents [[nodiscard]] attribute funtions after a macro without semicolon

2020-05-15 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:906
 // trailing semicolons from other constructs split to several lines.
-static bool tokenCanStartNewLine(const clang::Token &Tok) {
+static bool tokenCanStartNewLine(const FormatToken *Tok) {
   // Semicolon can be a null-statement, l_square can be a start of a macro or

nit: pass `Tok` by const reference (makes sure we don't have to deal with 
nullptr and as bonus will make this patch diff smaller).


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

https://reviews.llvm.org/D79990



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


[PATCH] D72534: Change default traversal in AST Matchers to ignore invisible nodes

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

LGTM aside from some documentation nits.




Comment at: clang/docs/ReleaseNotes.rst:255
+  This means that many uses of the ``ignoringImplicit()`` and similar matchers
+  is no longer necessary.  Clients of AST Matchers which wish to match on
+  implicit AST nodes can wrap their matcher in ``traverse(TK_AsIs, ...)`` or

is -> are

Also, I think we typically use single spacing after the full stop in the 
release notes.



Comment at: clang/docs/ReleaseNotes.rst:257-259
+  use ``TraversalKindScope`` if appropriate.  The ``clang-query`` tool also
+  uses ``IgnoreUnlessSpelledInSource`` by default.  The mode can be changed
+  using ``set traversal AsIs`` in the ``clang-query`` environment.

We also have release notes for clang-tools-extra that should be updated for the 
changes to clang-query.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72534



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


[clang] 8c24f33 - [IR][BFloat] Add BFloat IR type

2020-05-15 Thread Ties Stuij via cfe-commits

Author: Ties Stuij
Date: 2020-05-15T14:43:43+01:00
New Revision: 8c24f33158d81d5f4b0c5d27c2f07396f0f1484b

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

LOG: [IR][BFloat] Add BFloat IR type

Summary:
The BFloat IR type is introduced to provide support for, initially, the BFloat16
datatype introduced with the Armv8.6 architecture (optional from Armv8.2
onwards). It has an 8-bit exponent and a 7-bit mantissa and behaves like an IEEE
754 floating point IR type.

This is part of a patch series upstreaming Armv8.6 features. Subsequent patches
will upstream intrinsics support and C-lang support for BFloat.

Reviewers: SjoerdMeijer, rjmccall, rsmith, liutianle, RKSimon, craig.topper, 
jfb, LukeGeeson, sdesmalen, deadalnix, ctetreau

Subscribers: hiraditya, llvm-commits, danielkiss, arphaman, kristof.beyls, 
dexonsmith

Tags: #llvm

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

Added: 
llvm/test/Assembler/bfloat.ll

Modified: 
clang/lib/Sema/SemaOpenMP.cpp
llvm/docs/BitCodeFormat.rst
llvm/docs/LangRef.rst
llvm/include/llvm-c/Core.h
llvm/include/llvm/ADT/APFloat.h
llvm/include/llvm/Bitcode/LLVMBitCodes.h
llvm/include/llvm/IR/Constants.h
llvm/include/llvm/IR/DataLayout.h
llvm/include/llvm/IR/IRBuilder.h
llvm/include/llvm/IR/Type.h
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/MIRParser/MILexer.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/IR/Core.cpp
llvm/lib/IR/DataLayout.cpp
llvm/lib/IR/Function.cpp
llvm/lib/IR/LLVMContextImpl.cpp
llvm/lib/IR/LLVMContextImpl.h
llvm/lib/IR/Type.cpp
llvm/lib/Support/APFloat.cpp
llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/tools/llvm-c-test/echo.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 544dc6134387..e03b926bc581 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -14936,9 +14936,9 @@ static bool actOnOMPReductionKindClause(
 if (auto *ComplexTy = OrigType->getAs())
   Type = ComplexTy->getElementType();
 if (Type->isRealFloatingType()) {
-  llvm::APFloat InitValue =
-  llvm::APFloat::getAllOnesValue(Context.getTypeSize(Type),
- /*isIEEE=*/true);
+  llvm::APFloat InitValue = llvm::APFloat::getAllOnesValue(
+  Context.getFloatTypeSemantics(Type),
+  Context.getTypeSize(Type));
   Init = FloatingLiteral::Create(Context, InitValue, /*isexact=*/true,
  Type, ELoc);
 } else if (Type->isScalarType()) {

diff  --git a/llvm/docs/BitCodeFormat.rst b/llvm/docs/BitCodeFormat.rst
index dce84620fd7b..4fdccc87cfd2 100644
--- a/llvm/docs/BitCodeFormat.rst
+++ b/llvm/docs/BitCodeFormat.rst
@@ -1107,6 +1107,14 @@ TYPE_CODE_HALF Record
 The ``HALF`` record (code 10) adds a ``half`` (16-bit floating point) type to
 the type table.
 
+TYPE_CODE_BFLOAT Record
+^
+
+``[BFLOAT]``
+
+The ``BFLOAT`` record (code 23) adds a ``bfloat`` (16-bit brain floating point)
+type to the type table.
+
 TYPE_CODE_FLOAT Record
 ^^
 

diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 240dbd68e9e0..07320de7cf4b 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -2963,6 +2963,12 @@ Floating-Point Types
* - ``half``
  - 16-bit floating-point value
 
+   * - ``bfloat``
+ - 16-bit "brain" floating-point value (7-bit significand).  Provides the
+   same number of exponent bits as ``float``, so that it matches its 
dynamic
+   range, but with greatly reduced precision.  Used in Intel's AVX-512 BF16
+   extensions and Arm's ARMv8.6-A extensions, among others.
+
* - ``float``
  - 32-bit floating-point value
 
@@ -2970,7 +2976,7 @@ Floating-Point Types
  - 64-bit floating-point value
 
* - ``fp128``
- - 128-bit floating-point value (112-bit mantissa)
+ - 128-bit floating-point value (112-bit significand)
 
* - ``x86_fp80``
  -  80-bit floating-point value (X87)
@@ -3303,20 +3309,20 @@ number of digits. For example, NaN's, infinities, and 
other special
 values are represented in their IEEE hexadecimal format so that assembly
 and disassembly do not cause any bits to change in the constants.
 
-When using the hexadecimal form, constants of types half, float, and
-double are represented using the 16-digit form shown above (which
-matches the IEEE754 representation for double); half and float values
-must, however, be exac

[PATCH] D80009: [Analyzer][StreamChecker] Changed representation of stream error state - NFC.

2020-05-15 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, ASDenysPetrov, martong, Charusso, 
gamesh411, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a project: clang.

State of error flags for a stream is handled by having separate flags
that allow combination of multiple error states to be described with one
error state object.
After a failed function the error state is set in the stream state
and must not be determined later based on the last failed function
like before this change. The error state can not always be determined
from the last failed function and it was not the best design.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80009

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -19,14 +19,63 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+#include 
 
 using namespace clang;
 using namespace ento;
+using namespace std::placeholders;
 
 namespace {
 
 struct FnDescription;
 
+/// State of the stream error flags.
+/// Sometimes it is not known to the checker what error flags are set.
+/// This is indicated by setting more than one flag to true.
+/// This is an optimization to avoid state splits.
+/// In other words, if multiple flags are set it means a "batch" of execution
+/// paths, one for every single flag that is set to true. A stream can either be
+/// in FEOF or FERROR but not both at the same time.
+struct StreamErrorState {
+  /// There is an execution path with none of the error flags set.
+  bool NoError = true;
+  /// There is an execution path with EOF indicator set.
+  bool FEof = false;
+  /// There is an execution path with error indicator set.
+  bool FError = false;
+
+  bool isNoError() const { return NoError && !FEof && !FError; }
+  bool isFEof() const { return !NoError && FEof && !FError; }
+  bool isFError() const { return !NoError && !FEof && FError; }
+
+  bool operator==(const StreamErrorState &ES) const {
+return NoError == ES.NoError && FEof == ES.FEof && FError == ES.FError;
+  }
+
+  StreamErrorState operator|(const StreamErrorState &E) const {
+return {NoError || E.NoError, FEof || E.FEof, FError || E.FError};
+  }
+
+  StreamErrorState operator&(const StreamErrorState &E) const {
+return {NoError && E.NoError, FEof && E.FEof, FError && E.FError};
+  }
+
+  StreamErrorState operator~() const { return {!NoError, !FEof, !FError}; }
+
+  /// Returns if the StreamErrorState is a valid object.
+  operator bool() const { return NoError || FEof || FError; }
+
+  void Profile(llvm::FoldingSetNodeID &ID) const {
+ID.AddBoolean(NoError);
+ID.AddBoolean(FEof);
+ID.AddBoolean(FError);
+  }
+};
+
+const StreamErrorState ErrorNone{true, false, false};
+const StreamErrorState ErrorFEof{false, true, false};
+const StreamErrorState ErrorFError{false, false, true};
+
 /// Full state information about a stream pointer.
 struct StreamState {
   /// The last file operation called in the stream.
@@ -40,53 +89,24 @@
 OpenFailed /// The last open operation has failed.
   } State;
 
-  /// The error state of a stream.
-  /// Valid only if the stream is opened.
-  /// It is assumed that feof and ferror flags are never true at the same time.
-  enum ErrorKindTy {
-/// No error flag is set (or stream is not open).
-NoError,
-/// EOF condition (`feof` is true).
-FEof,
-/// Other generic (non-EOF) error (`ferror` is true).
-FError,
-/// Unknown error flag is set (or none), the meaning depends on the last
-/// operation.
-Unknown
-  } ErrorState = NoError;
+  /// State of the error flags.
+  /// Ignored in non-opened stream state but must be NoError.
+  StreamErrorState ErrorState;
 
   bool isOpened() const { return State == Opened; }
   bool isClosed() const { return State == Closed; }
   bool isOpenFailed() const { return State == OpenFailed; }
 
-  bool isNoError() const {
-assert(State == Opened && "Error undefined for closed stream.");
-return ErrorState == NoError;
-  }
-  bool isFEof() const {
-assert(State == Opened && "Error undefined for closed stream.");
-return ErrorState == FEof;
-  }
-  bool isFError() const {
-assert(State == Opened && "Error undefined for closed stream.");
-return ErrorState == FError;
-  }
-  bool isUnknown() const {
-assert(State == Opened && "Error undefined for closed stream.");
-return ErrorState == Unknown;
-  }
-
   bool operator==(const StreamState &X) const {
-// In not opened state error should always NoError.
+

[PATCH] D72530: Set traversal explicitly where needed in clang-tidy

2020-05-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

The changes here look reasonable, but can some of this code be simplified to 
use the default behavior and less complex matchers that don't have to carefully 
ignore implicit nodes? This would demonstrate that the feature really is an 
improvement over the status quo and would also exercise more test code with the 
new defaults demonstrating equivalence. I'm not envisioning anything onerous, 
more just wondering if you think there is some low-hanging fruit that could be 
picked rather than converting everything to AsIs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72530



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


[PATCH] D80008: [clang-format] [PR45942] [[nodiscard]] causes && to be miss interpreted as BinaryOperators

2020-05-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: krasimir, JakeMerdichAMD, mitchell-stellar, 
sylvestre.ledru, Abpostelnicu.
MyDeveloperDay added projects: clang, clang-format.

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

With Chromium style (although that is not important) its just it defines 
PointerAligmment: Left

The following arguments `S&&` are formatted differently depending on if the 
class has an attribute between it and the class identifier

  class S {
S(S&&) = default;
  };
  
  class [[nodiscard]] S {
S(S &&) = default;
  };

The prescense of [[nodiscard]] between the `class/struct` and the `{` causes 
the `{` to be incorrectly seen as a `TT_FunctionLBrace` which in turn 
transforms all the && to be `TT_BinaryOperators` rather than 
`TT_PointerOrReference`, as binary operators other spacing rules come into play 
causing a miss format

This revision resolves this by allowing the parseRecord to consider the 
[[nodisscard]]


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80008

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7672,6 +7672,30 @@
MultiLineFunctions);
 }
 
+TEST_F(FormatTest, AttributeClass) {
+  FormatStyle Style = getChromiumStyle(FormatStyle::LK_Cpp);
+  verifyFormat("class S {\n"
+   "  S(S&&) = default;\n"
+   "};",
+   Style);
+  verifyFormat("class [[nodiscard]] S {\n"
+   "  S(S&&) = default;\n"
+   "};",
+   Style);
+  verifyFormat("class __attribute((maybeunused)) S {\n"
+   "  S(S&&) = default;\n"
+   "};",
+   Style);
+  verifyFormat("struct S {\n"
+   "  S(S&&) = default;\n"
+   "};",
+   Style);
+  verifyFormat("struct [[nodiscard]] S {\n"
+   "  S(S&&) = default;\n"
+   "};",
+   Style);
+}
+
 TEST_F(FormatTest, AttributePenaltyBreaking) {
   FormatStyle Style = getLLVMStyle();
   verifyFormat("void ABCDEFGH::ABCDEFGHIJKLMN(\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2401,7 +2401,7 @@
   // it is often token-pasted.
   while (FormatTok->isOneOf(tok::identifier, tok::coloncolon, tok::hashhash,
 tok::kw___attribute, tok::kw___declspec,
-tok::kw_alignas) ||
+tok::kw_alignas, tok::l_square, tok::r_square) ||
  ((Style.Language == FormatStyle::LK_Java ||
Style.Language == FormatStyle::LK_JavaScript) &&
   FormatTok->isOneOf(tok::period, tok::comma))) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7672,6 +7672,30 @@
MultiLineFunctions);
 }
 
+TEST_F(FormatTest, AttributeClass) {
+  FormatStyle Style = getChromiumStyle(FormatStyle::LK_Cpp);
+  verifyFormat("class S {\n"
+   "  S(S&&) = default;\n"
+   "};",
+   Style);
+  verifyFormat("class [[nodiscard]] S {\n"
+   "  S(S&&) = default;\n"
+   "};",
+   Style);
+  verifyFormat("class __attribute((maybeunused)) S {\n"
+   "  S(S&&) = default;\n"
+   "};",
+   Style);
+  verifyFormat("struct S {\n"
+   "  S(S&&) = default;\n"
+   "};",
+   Style);
+  verifyFormat("struct [[nodiscard]] S {\n"
+   "  S(S&&) = default;\n"
+   "};",
+   Style);
+}
+
 TEST_F(FormatTest, AttributePenaltyBreaking) {
   FormatStyle Style = getLLVMStyle();
   verifyFormat("void ABCDEFGH::ABCDEFGHIJKLMN(\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2401,7 +2401,7 @@
   // it is often token-pasted.
   while (FormatTok->isOneOf(tok::identifier, tok::coloncolon, tok::hashhash,
 tok::kw___attribute, tok::kw___declspec,
-tok::kw_alignas) ||
+tok::kw_alignas, tok::l_square, tok::r_square) ||
  ((Style.Language == FormatStyle::LK_Java ||
Style.Language == FormatStyle::LK_JavaScript) &&
   FormatTok->isOneOf(tok::period, tok::comma))) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/

[PATCH] D78190: Add Bfloat IR type

2020-05-15 Thread Ties Stuij via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8c24f33158d8: [IR][BFloat] Add BFloat IR type (authored by 
stuij).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78190

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  llvm/docs/BitCodeFormat.rst
  llvm/docs/LangRef.rst
  llvm/include/llvm-c/Core.h
  llvm/include/llvm/ADT/APFloat.h
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Type.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/MIRParser/MILexer.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/DataLayout.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/LLVMContextImpl.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/IR/Type.cpp
  llvm/lib/Support/APFloat.cpp
  llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/Assembler/bfloat.ll
  llvm/tools/llvm-c-test/echo.cpp

Index: llvm/tools/llvm-c-test/echo.cpp
===
--- llvm/tools/llvm-c-test/echo.cpp
+++ llvm/tools/llvm-c-test/echo.cpp
@@ -72,6 +72,8 @@
 return LLVMVoidTypeInContext(Ctx);
   case LLVMHalfTypeKind:
 return LLVMHalfTypeInContext(Ctx);
+  case LLVMBFloatTypeKind:
+return LLVMHalfTypeInContext(Ctx);
   case LLVMFloatTypeKind:
 return LLVMFloatTypeInContext(Ctx);
   case LLVMDoubleTypeKind:
Index: llvm/test/Assembler/bfloat.ll
===
--- /dev/null
+++ llvm/test/Assembler/bfloat.ll
@@ -0,0 +1,38 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s --check-prefix=ASSEM-DISASS
+; RUN: opt < %s -O3 -S | FileCheck %s --check-prefix=OPT
+; RUN: verify-uselistorder %s
+; Basic smoke tests for bfloat type.
+
+define bfloat @check_bfloat(bfloat %A) {
+; ASSEM-DISASS: ret bfloat %A
+ret bfloat %A
+}
+
+define bfloat @check_bfloat_literal() {
+; ASSEM-DISASS: ret bfloat 0xR3149
+ret bfloat 0xR3149
+}
+
+define <4 x bfloat> @check_fixed_vector() {
+; ASSEM-DISASS: ret <4 x bfloat> %tmp
+  %tmp = fadd <4 x bfloat> undef, undef
+  ret <4 x bfloat> %tmp
+}
+
+define  @check_vector() {
+; ASSEM-DISASS: ret  %tmp
+  %tmp = fadd  undef, undef
+  ret  %tmp
+}
+
+define bfloat @check_bfloat_constprop() {
+  %tmp = fadd bfloat 0xR40C0, 0xR40C0
+; OPT: 0xR4140
+  ret bfloat %tmp
+}
+
+define float @check_bfloat_convert() {
+  %tmp = fpext bfloat 0xR4C8D to float
+; OPT: 0x4191A000
+  ret float %tmp
+}
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -11526,8 +11526,9 @@
   MVT LogicVT = VT;
   if (EltVT == MVT::f32 || EltVT == MVT::f64) {
 Zero = DAG.getConstantFP(0.0, DL, EltVT);
-AllOnes = DAG.getConstantFP(
-APFloat::getAllOnesValue(EltVT.getSizeInBits(), true), DL, EltVT);
+APFloat AllOnesValue = APFloat::getAllOnesValue(
+SelectionDAG::EVTToAPFloatSemantics(EltVT), EltVT.getSizeInBits());
+AllOnes = DAG.getConstantFP(AllOnesValue, DL, EltVT);
 LogicVT =
 MVT::getVectorVT(EltVT == MVT::f64 ? MVT::i64 : MVT::i32, Mask.size());
   } else {
Index: llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
===
--- llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
+++ llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
@@ -323,6 +323,7 @@
   }
   case Type::FunctionTyID:
   case Type::VoidTyID:
+  case Type::BFloatTyID:
   case Type::X86_FP80TyID:
   case Type::FP128TyID:
   case Type::PPC_FP128TyID:
Index: llvm/lib/Support/APFloat.cpp
===
--- llvm/lib/Support/APFloat.cpp
+++ llvm/lib/Support/APFloat.cpp
@@ -69,6 +69,7 @@
   };
 
   static const fltSemantics semIEEEhalf = {15, -14, 11, 16};
+  static const fltSemantics semBFloat = {127, -126, 8, 16};
   static const fltSemantics semIEEEsingle = {127, -126, 24, 32};
   static const fltSemantics semIEEEdouble = {1023, -1022, 53, 64};
   static const fltSemantics semIEEEquad = {16383, -16382, 113, 128};
@@ -117,6 +118,8 @@
 switch (S) {
 case S_IEEEhalf:
   return IEEEhalf();
+case S_BFloat:
+  return BFloat();
 case S_IEEEsingle:
   return IEEEsingle();
 case S_IEEEdouble:
@@ -135,6 +138,8 @@
   APFloatBase::SemanticsToEnum(const llvm::fltSemantics &Sem) {
 if (&Sem == &llvm::APFloat::IEEEhalf())
   return S_IEEEhalf;
+else if (&Sem == &l

[PATCH] D79990: [clang-format] [PR45614] Incorrectly indents [[nodiscard]] attribute funtions after a macro without semicolon

2020-05-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 264231.
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added a comment.

Change to const &


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

https://reviews.llvm.org/D79990

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7672,6 +7672,37 @@
MultiLineFunctions);
 }
 
+TEST_F(FormatTest, AttributesAfterMacro) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("MACRO;\n"
+   "__attribute__((maybe_unused)) int foo() {\n"
+   "  //...\n"
+   "}");
+
+  verifyFormat("MACRO;\n"
+   "[[nodiscard]] int foo() {\n"
+   "  //...\n"
+   "}");
+
+  EXPECT_EQ("MACRO\n\n"
+"__attribute__((maybe_unused)) int foo() {\n"
+"  //...\n"
+"}",
+format("MACRO\n\n"
+   "__attribute__((maybe_unused)) int foo() {\n"
+   "  //...\n"
+   "}"));
+
+  EXPECT_EQ("MACRO\n\n"
+"[[nodiscard]] int foo() {\n"
+"  //...\n"
+"}",
+format("MACRO\n\n"
+   "[[nodiscard]] int foo() {\n"
+   "  //...\n"
+   "}"));
+}
+
 TEST_F(FormatTest, AttributePenaltyBreaking) {
   FormatStyle Style = getLLVMStyle();
   verifyFormat("void ABCDEFGH::ABCDEFGHIJKLMN(\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -903,11 +903,11 @@
 // Here we blacklist certain tokens that are not usually the first token in an
 // unwrapped line. This is used in attempt to distinguish macro calls without
 // trailing semicolons from other constructs split to several lines.
-static bool tokenCanStartNewLine(const clang::Token &Tok) {
+static bool tokenCanStartNewLine(const FormatToken &Tok) {
   // Semicolon can be a null-statement, l_square can be a start of a macro or
   // a C++11 attribute, but this doesn't seem to be common.
   return Tok.isNot(tok::semi) && Tok.isNot(tok::l_brace) &&
- Tok.isNot(tok::l_square) &&
+ Tok.isNot(TT_AttributeSquare) &&
  // Tokens that can only be used as binary operators and a part of
  // overloaded operator names.
  Tok.isNot(tok::period) && Tok.isNot(tok::periodstar) &&
@@ -1441,7 +1441,7 @@
 : CommentsBeforeNextToken.front()->NewlinesBefore > 0;
 
 if (FollowedByNewline && (Text.size() >= 5 || FunctionLike) &&
-tokenCanStartNewLine(FormatTok->Tok) && Text == Text.upper()) {
+tokenCanStartNewLine(*FormatTok) && Text == Text.upper()) {
   addUnwrappedLine();
   return;
 }


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7672,6 +7672,37 @@
MultiLineFunctions);
 }
 
+TEST_F(FormatTest, AttributesAfterMacro) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("MACRO;\n"
+   "__attribute__((maybe_unused)) int foo() {\n"
+   "  //...\n"
+   "}");
+
+  verifyFormat("MACRO;\n"
+   "[[nodiscard]] int foo() {\n"
+   "  //...\n"
+   "}");
+
+  EXPECT_EQ("MACRO\n\n"
+"__attribute__((maybe_unused)) int foo() {\n"
+"  //...\n"
+"}",
+format("MACRO\n\n"
+   "__attribute__((maybe_unused)) int foo() {\n"
+   "  //...\n"
+   "}"));
+
+  EXPECT_EQ("MACRO\n\n"
+"[[nodiscard]] int foo() {\n"
+"  //...\n"
+"}",
+format("MACRO\n\n"
+   "[[nodiscard]] int foo() {\n"
+   "  //...\n"
+   "}"));
+}
+
 TEST_F(FormatTest, AttributePenaltyBreaking) {
   FormatStyle Style = getLLVMStyle();
   verifyFormat("void ABCDEFGH::ABCDEFGHIJKLMN(\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -903,11 +903,11 @@
 // Here we blacklist certain tokens that are not usually the first token in an
 // unwrapped line. This is used in attempt to distinguish macro calls without
 // trailing semicolons from other constructs split to several lines.
-static bool tokenCanStartNewLine(const clang::Token &Tok) {
+static bool tokenCanStartNewLine(const FormatToken &Tok) {
   // Semicolon can be a null-statement, l_square can be a start of 

[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-15 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added a comment.

In D79704#2038280 , @NoQ wrote:

> In D79704#2038257 , @Szelethus wrote:
>
> > In D79704#2037100 , @NoQ wrote:
> >
> > > > The code changes make me feel like we're doing a lot of chore (and make 
> > > > it super easy to forget checking for parameters explicitly).
> > >
> > > I wouldn't mind having a common base class for these regions. 
> > > `DeclRegion` should probably be dropped in this case, in order to avoid 
> > > dealing with multiple inheritance. And it's definitely the one that needs 
> > > to be dropped because it currently does nothing except "inheritance for 
> > > code reuse": there are basically no other common properties between its 
> > > sub-classes than the accidental code reuse in its methods.
> >
> >
> > Totally. Something like a `VarRegionBase` but with a more clever name.
>
>
> We can even call it `VarRegion` and have sub-classes be `ParamVarRegion` and 
> `NonParamVarRegion` or something like that.


Do you mean `getDecl()` should be pure virtual with different implementation 
for `ParamVarRegion` (retrieves dynamically based on its `Index`) and 
`NonParamVarRegion` (stores). However, there //are// some places in the code 
that check for `DeclRegion` and use its `getDecl()` so to avoid code 
duplication we can keep `DeclRegion`, but remove storing of `Decl` from it and 
make `getDecl()` pure virtual already at that level.




Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:191
+const ParmVarDecl *ParamRegion::getDecl() const {
+  const Decl *D = getStackFrame()->getDecl();
+

NoQ wrote:
> baloghadamsoftware wrote:
> > NoQ wrote:
> > > baloghadamsoftware wrote:
> > > > NoQ wrote:
> > > > > This doesn't work when the callee is unknown.
> > > > Please give me an example where the callee is unknown. As I wrote, 
> > > > originally I put a `getExpr()` method here as well and `getType()` fell 
> > > > back to it if it could not find the `Decl()`. However, it was never 
> > > > invoked on the whole test suite. (I put an `assert(false)` into it, and 
> > > > did not get a crash.
> > > > Please give me an example where the callee is unknown.
> > > 
> > > >>! In D79704#2034571, @NoQ wrote:
> > > >>>! In D79704#2032947, @Szelethus wrote:
> > > >> Could you give a specific code example? 
> > > > 
> > > > ```lang=c++
> > > > struct S {
> > > >   S() {
> > > > this; // What region does 'this' point to...
> > > >   }
> > > > };
> > > > 
> > > > void foo(void (*bar)(S)) {
> > > >   bar(S()); // ...in this invocation?
> > > > }
> > > > ```
> > OK, but it still does not crash the analyzer, even if I enable creation of 
> > stack frames for all the callees, even for those without definition. What 
> > else should I do to enforce the crash (null pointer dereference)? Try to 
> > use `getParameterLocation()` in a unit test?
> Yes. I demonstrated how you can get the region without a decl but you should 
> turn this into a test that actually calls one of the problematic functions. 
> Like, `clang_analyzer_dump()` it or something.
Of  course I tried `clang_analyzer_explain()`, but neither 
`clang_analyzer_dump()` helps. I also tried a unit test now where I call 
`getParameterLocation()` explicitly. It turns out that parameter regions are 
never created for functions without `Decl` because of the first lines in 
`CallEvent::getCalleeAnalysisDeclContext()`. This function //needs// the `Decl` 
to retrieve the `AnalysisDeclContext` of the callee, which is needed to 
retrieve its stack  frame by `getCalleeStackFrame()`. Without stack frame we do 
not create `ParamRegion`. The other two functions creating `ParamRegion` 
(`CallEvent::addParameterValuesToBindings` and the newly created 
`MemRegionManager::getRegionForParam`) start from `ParmVarDecl` which always 
belongs to a `Decl`. So we can safely assume that currently all parameter 
regions have a `Decl`. Of course, this can be changed in the future, but I must 
not include dead code in a patch that cannot even be tested in the current 
phase. Even creation of callee stack frame for functions without //definition// 
is not part of this patch, but of the subsequent one.


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

https://reviews.llvm.org/D79704



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


[PATCH] D79325: [clang-format] [PR42164] Add Option to Break before While

2020-05-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 264235.
MyDeveloperDay added a comment.

Use BeforeWhile and not IndentBraces to wrap the line
Update the release notes


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

https://reviews.llvm.org/D79325

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1703,6 +1703,22 @@
 format("try{foo();}catch(...){baz();}", Style));
 }
 
+TEST_F(FormatTest, BeforeWhile) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BraceBreakingStyle::BS_Custom;
+
+  verifyFormat("do {\n"
+   "  foo();\n"
+   "} while (1);",
+   Style);
+  Style.BraceWrapping.BeforeWhile = true;
+  verifyFormat("do {\n"
+   "  foo();\n"
+   "}\n"
+   "while (1);",
+   Style);
+}
+
 //===--===//
 // Tests for classes, namespaces, etc.
 //===--===//
@@ -13066,6 +13082,7 @@
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeCatch);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeElse);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeLambdaBody);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeWhile);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, IndentBraces);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyFunction);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyRecord);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2167,7 +2167,7 @@
   if (FormatTok->Tok.is(tok::l_brace)) {
 CompoundStatementIndenter Indenter(this, Style, Line->Level);
 parseBlock(/*MustBeDeclaration=*/false);
-if (Style.BraceWrapping.IndentBraces)
+if (Style.BraceWrapping.BeforeWhile)
   addUnwrappedLine();
   } else {
 addUnwrappedLine();
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -589,6 +589,7 @@
 IO.mapOptional("BeforeCatch", Wrapping.BeforeCatch);
 IO.mapOptional("BeforeElse", Wrapping.BeforeElse);
 IO.mapOptional("BeforeLambdaBody", Wrapping.BeforeLambdaBody);
+IO.mapOptional("BeforeWhile", Wrapping.BeforeWhile);
 IO.mapOptional("IndentBraces", Wrapping.IndentBraces);
 IO.mapOptional("SplitEmptyFunction", Wrapping.SplitEmptyFunction);
 IO.mapOptional("SplitEmptyRecord", Wrapping.SplitEmptyRecord);
@@ -672,12 +673,24 @@
   if (Style.BreakBeforeBraces == FormatStyle::BS_Custom)
 return Style;
   FormatStyle Expanded = Style;
-  Expanded.BraceWrapping = {false, false, FormatStyle::BWACS_Never,
-false, false, false,
-false, false, false,
-false, false, false,
-false, false, true,
-true,  true};
+  Expanded.BraceWrapping = {/*AfterCaseLabel=*/false,
+/*AfterClass=*/false,
+/*AfterControlStatement=*/FormatStyle::BWACS_Never,
+/*AfterEnum=*/false,
+/*AfterFunction=*/false,
+/*AfterNamespace=*/false,
+/*AfterObjCDeclaration=*/false,
+/*AfterStruct=*/false,
+/*AfterUnion=*/false,
+/*AfterExternBlock=*/false,
+/*BeforeCatch=*/false,
+/*BeforeElse=*/false,
+/*BeforeLambdaBody=*/false,
+/*BeforeWhile=*/false,
+/*IndentBraces=*/false,
+/*SplitEmptyFunction=*/true,
+/*SplitEmptyRecord=*/true,
+/*SplitEmptyNamespace=*/true};
   switch (Style.BreakBeforeBraces) {
   case FormatStyle::BS_Linux:
 Expanded.BraceWrapping.AfterClass = true;
@@ -728,12 +741,25 @@
 Expanded.BraceWrapping.BeforeLambdaBody = true;
 break;
   case FormatStyle::BS_GNU:
-Expanded.BraceWrapping = {true,  true, FormatStyle::BWACS_Always,
-  true,  true, true,
-  true,  true, true,
-  true,  true, true,
-  false, true, true,
-  

[PATCH] D76420: Prevent IR-gen from emitting consteval declarations

2020-05-15 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 264236.
Tyker marked 12 inline comments as done.
Tyker added a comment.

addressed comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76420

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ConstantEmitter.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCXX/cxx2a-consteval.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++2a -fsyntax-only -Wno-unused-value %s -verify
+// RUN: %clang_cc1 -std=c++2a -emit-llvm-only -Wno-unused-value %s -verify
 
 typedef __SIZE_TYPE__ size_t;
 
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1578,7 +1578,7 @@
 namespace CompoundLiteral {
   // Matching GCC, file-scope array compound literals initialized by constants
   // are lifetime-extended.
-  constexpr int *p = (int*)(int[1]){3}; // expected-warning {{C99}}
+  constexpr int *p = (int*)(int[1]){2 + __builtin_is_constant_evaluated()}; // expected-warning {{C99}}
   static_assert(*p == 3, "");
   static_assert((int[2]){1, 2}[1] == 2, ""); // expected-warning {{C99}}
 
Index: clang/test/CodeGenCXX/cxx2a-consteval.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx2a-consteval.cpp
@@ -0,0 +1,212 @@
+// NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+// RUN: %clang_cc1 -emit-llvm %s -std=c++2a -o %t.ll
+// RUN: FileCheck -check-prefix=EVAL -input-file=%t.ll %s
+// RUN: FileCheck -check-prefix=EVAL-FN -input-file=%t.ll %s
+// RUN: FileCheck -check-prefix=EVAL-STATIC -input-file=%t.ll %s
+// RUN: %clang_cc1 -emit-llvm %s -Dconsteval="" -std=c++2a -o %t.ll
+// RUNA: FileCheck -check-prefix=EXPR -input-file=%t.ll %s
+
+// there is two version of symbol checks to ensure
+// that the symbol we are looking for are correct
+// EVAL-NOT: @__cxx_global_var_init()
+// EXPR: @__cxx_global_var_init()
+
+// EVAL-NOT: @_Z4ret7v()
+// EXPR: @_Z4ret7v()
+consteval int ret7() {
+  return 7;
+}
+
+int test_ret7() {
+// EVAL-FN-LABEL: @_Z9test_ret7v(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:[[I:%.*]] = alloca i32, align 4
+// EVAL-FN-NEXT:store i32 7, i32* [[I]], align 4
+// EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* [[I]], align 4
+// EVAL-FN-NEXT:ret i32 [[TMP0]]
+//
+  int i = ret7();
+  return i;
+}
+
+// EVAL-STATIC: @global_i = global i32 7, align 4
+int global_i = ret7();
+
+// EVAL-STATIC: @_ZL7i_const = internal constant i32 5, align 4
+constexpr int i_const = 5;
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+consteval const int& retI() {
+  return i_const;
+}
+
+const int& test_retRefI() {
+// EVAL-FN-LABEL: @_Z12test_retRefIv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:ret i32* @_ZL7i_const
+//
+  return retI();
+}
+
+int test_retI() {
+// EVAL-FN-LABEL: @_Z9test_retIv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* @_ZL7i_const, align 4
+// EVAL-FN-NEXT:ret i32 [[TMP0]]
+//
+  return retI();
+}
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+consteval const int* retIPtr() {
+  return &i_const;
+}
+
+int test_retIPtr() {
+// EVAL-FN-LABEL: @_Z12test_retIPtrv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* @_ZL7i_const, align 4
+// EVAL-FN-NEXT:ret i32 [[TMP0]]
+//
+  return *retIPtr();
+}
+
+const int* test_retPIPtr() {
+// EVAL-FN-LABEL: @_Z13test_retPIPtrv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:ret i32* @_ZL7i_const
+//
+  return retIPtr();
+}
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+consteval const int&& retIRRef() {
+  return static_cast(i_const);
+}
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+const int&& test_retIRRef() {
+  return static_cast(retIRRef());
+}
+
+int test_retIRRefI() {
+// EVAL-FN-LABEL: @_Z14test_retIRRefIv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* @_ZL7i_const, align 4
+// EVAL-FN-NEXT:ret i32 [[TMP0]]
+//
+  return retIRRef();
+}
+
+struct Agg {
+  int a;
+  long b;
+};
+
+// EVAL-NOT: @_Z6re

[PATCH] D50078: clang-format: support aligned nested conditionals formatting

2020-05-15 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 264234.
Typz added a comment.

Fix random crash on windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D50078

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/ContinuationIndenter.h
  clang/lib/Format/WhitespaceManager.cpp
  clang/lib/Format/WhitespaceManager.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5950,6 +5950,124 @@
" // comment\n"
" ? a = b\n"
" : a;");
+
+  // Chained conditionals
+  FormatStyle Style = getLLVMStyle();
+  Style.ColumnLimit = 70;
+  Style.AlignOperands = true;
+  verifyFormat("return  ? \n"
+   "   : bb ? \n"
+   ": ;",
+   Style);
+  verifyFormat("return  ? \n"
+   "   : bb ? \n"
+   ": ;",
+   Style);
+  verifyFormat("return aa ? \n"
+   "   :  ? \n"
+   "  : ;",
+   Style);
+  verifyFormat("return  ? \n"
+   "   : bb ? 22\n"
+   ": 33;",
+   Style);
+  verifyFormat("return  ? \n"
+   "   : bb ? \n"
+   "   : cc ? \n"
+   ": ;",
+   Style);
+  verifyFormat("return  ? (aaa ? bbb : ccc)\n"
+   "   : bb ? \n"
+   ": ;",
+   Style);
+  verifyFormat("return  ? \n"
+   "   : bb ? \n"
+   ": (aaa ? bbb : ccc);",
+   Style);
+  verifyFormat(
+  "return  ? (a ? bb\n"
+  " : cc)\n"
+  "   : bb ? \n"
+  ": ;",
+  Style);
+  verifyFormat(
+  "return a? (a ? bb\n"
+  " : cc)\n"
+  "   : bb ? \n"
+  ": ;",
+  Style);
+  verifyFormat(
+  "return a? a = (a ? bb\n"
+  " : dd)\n"
+  "   : bb ? \n"
+  ": ;",
+  Style);
+  verifyFormat(
+  "return a? a + (a ? bb\n"
+  " : dd)\n"
+  "   : bb ? \n"
+  ": ;",
+  Style);
+  verifyFormat(
+  "return a? \n"
+  "   : bb ? \n"
+  ": a + (a ? bb\n"
+  " : dd)\n",
+  Style);
+  verifyFormat(
+  "return  ? \n"
+  "   : bb ? \n"
+  ": (a ? bb\n"
+  " : cc);",
+  Style);
+  verifyFormat(
+  "return  ? (a ? bb\n"
+  "   : ccc ? dd\n"
+  " : ee)\n"
+  "   : bb ? \n"
+  ": ;",
+  Style);
+  verifyFormat(
+  "return  ? (aa? bb\n"
+  "   : ccc ? dd\n"
+  " : ee)\n"
+  "   : bb ? \n"
+  ": ;",
+  Style);

[PATCH] D79990: [clang-format] [PR45614] Incorrectly indents [[nodiscard]] attribute funtions after a macro without semicolon

2020-05-15 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

Please see 
https://firefox-source-docs.mozilla.org/code-quality/coding-style/format_cpp_code_with_clang-format.html


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

https://reviews.llvm.org/D79990



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


[PATCH] D76420: Prevent IR-gen from emitting consteval declarations

2020-05-15 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 264237.
Tyker added a comment.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76420

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ConstantEmitter.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCXX/cxx2a-consteval.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++2a -fsyntax-only -Wno-unused-value %s -verify
+// RUN: %clang_cc1 -std=c++2a -emit-llvm-only -Wno-unused-value %s -verify
 
 typedef __SIZE_TYPE__ size_t;
 
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1578,7 +1578,7 @@
 namespace CompoundLiteral {
   // Matching GCC, file-scope array compound literals initialized by constants
   // are lifetime-extended.
-  constexpr int *p = (int*)(int[1]){3}; // expected-warning {{C99}}
+  constexpr int *p = (int*)(int[1]){2 + __builtin_is_constant_evaluated()}; // expected-warning {{C99}}
   static_assert(*p == 3, "");
   static_assert((int[2]){1, 2}[1] == 2, ""); // expected-warning {{C99}}
 
Index: clang/test/CodeGenCXX/cxx2a-consteval.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx2a-consteval.cpp
@@ -0,0 +1,212 @@
+// NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+// RUN: %clang_cc1 -emit-llvm %s -std=c++2a -o %t.ll
+// RUN: FileCheck -check-prefix=EVAL -input-file=%t.ll %s
+// RUN: FileCheck -check-prefix=EVAL-FN -input-file=%t.ll %s
+// RUN: FileCheck -check-prefix=EVAL-STATIC -input-file=%t.ll %s
+// RUN: %clang_cc1 -emit-llvm %s -Dconsteval="" -std=c++2a -o %t.ll
+// RUN: FileCheck -check-prefix=EXPR -input-file=%t.ll %s
+
+// there is two version of symbol checks to ensure
+// that the symbol we are looking for are correct
+// EVAL-NOT: @__cxx_global_var_init()
+// EXPR: @__cxx_global_var_init()
+
+// EVAL-NOT: @_Z4ret7v()
+// EXPR: @_Z4ret7v()
+consteval int ret7() {
+  return 7;
+}
+
+int test_ret7() {
+  // EVAL-FN-LABEL: @_Z9test_ret7v(
+  // EVAL-FN-NEXT:  entry:
+  // EVAL-FN-NEXT:[[I:%.*]] = alloca i32, align 4
+  // EVAL-FN-NEXT:store i32 7, i32* [[I]], align 4
+  // EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* [[I]], align 4
+  // EVAL-FN-NEXT:ret i32 [[TMP0]]
+  //
+  int i = ret7();
+  return i;
+}
+
+// EVAL-STATIC: @global_i = global i32 7, align 4
+int global_i = ret7();
+
+// EVAL-STATIC: @_ZL7i_const = internal constant i32 5, align 4
+constexpr int i_const = 5;
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+consteval const int &retI() {
+  return i_const;
+}
+
+const int &test_retRefI() {
+  // EVAL-FN-LABEL: @_Z12test_retRefIv(
+  // EVAL-FN-NEXT:  entry:
+  // EVAL-FN-NEXT:ret i32* @_ZL7i_const
+  //
+  return retI();
+}
+
+int test_retI() {
+  // EVAL-FN-LABEL: @_Z9test_retIv(
+  // EVAL-FN-NEXT:  entry:
+  // EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* @_ZL7i_const, align 4
+  // EVAL-FN-NEXT:ret i32 [[TMP0]]
+  //
+  return retI();
+}
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+consteval const int *retIPtr() {
+  return &i_const;
+}
+
+int test_retIPtr() {
+  // EVAL-FN-LABEL: @_Z12test_retIPtrv(
+  // EVAL-FN-NEXT:  entry:
+  // EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* @_ZL7i_const, align 4
+  // EVAL-FN-NEXT:ret i32 [[TMP0]]
+  //
+  return *retIPtr();
+}
+
+const int *test_retPIPtr() {
+  // EVAL-FN-LABEL: @_Z13test_retPIPtrv(
+  // EVAL-FN-NEXT:  entry:
+  // EVAL-FN-NEXT:ret i32* @_ZL7i_const
+  //
+  return retIPtr();
+}
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+consteval const int &&retIRRef() {
+  return static_cast(i_const);
+}
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+const int &&test_retIRRef() {
+  return static_cast(retIRRef());
+}
+
+int test_retIRRefI() {
+  // EVAL-FN-LABEL: @_Z14test_retIRRefIv(
+  // EVAL-FN-NEXT:  entry:
+  // EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* @_ZL7i_const, align 4
+  // EVAL-FN-NEXT:ret i32 [[TMP0]]
+  //
+  return retIRRef();
+}
+
+struct Agg {
+  int a;
+  long b;
+};
+
+// EVAL-NOT: @_Z6re

[PATCH] D76420: Prevent IR-gen from emitting consteval declarations

2020-05-15 Thread Tyker via Phabricator via cfe-commits
Tyker added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:6807-6808
 
+llvm::SaveAndRestore InConstantContext(Info.InConstantContext, true);
 return StmtVisitorTy::Visit(E->getSubExpr());
   }

rsmith wrote:
> I don't think this is really right, but perhaps the difference isn't 
> observable right now. What I'm thinking of is a case like this:
> 
> ```
> consteval int do_stuff() {
>   __builtin_produce_diagnostic("hello world\n");
>   return 42;
> }
> constexpr int f() {
>   int n = do_stuff();
>   return n;
> }
> int k = f();
> ```
> 
> Here, I would expect that when we process the immediate invocation of 
> `do_stuff()` in `f`, we would immediately evaluate it, including issuing its 
> diagnostic. And then for all subsequent calls to `f()`, we would never 
> re-evaluate it.
> 
> I can see a couple of ways this could work:
> 
>  * Whenever we create a `ConstantExpr`, we always evaluate it and fill in the 
> `APValue` result; it's never absent except perhaps in a window of time 
> between forming that AST node and deciding for sure that we want to keep it 
> (for nested immediate invocation handling).
>  * Whenever constant evaluation meets a `ConstantExpr` that doesn't have an 
> associated result yet, it triggers that result to be computed and cached, as 
> a separate evaluation.
> 
> I think the first of those two approaches is much better: lazily evaluating 
> the `ConstantExpr` will require us to save update records if we're writing an 
> AST file, and will mean we don't always have an obvious point where the 
> side-effects from builtin consteval functions (eg, reflection-driven actions) 
> happen.
> 
> So I think the right thing to do is probably to say that a `ConstantExpr` 
> that hasn't yet had its `APValue` result filled in is non-constant for now, 
> and to ensure that everywhere that creates a `ConstantExpr` always eventually 
> either removes it again or fills in the result.
ok seems reasonable.




Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1364-1365
+llvm::Constant *ConstantEmitter::tryEmitConstantExpr(const ConstantExpr *CE) {
+  if (!CE->isImmediateInvocation())
+return nullptr;
+  const Expr *Inner = CE->getSubExpr()->IgnoreImplicit();

rsmith wrote:
> I'm fine with having this check for now, but eventually I think we should do 
> this for all `ConstantExpr`s, regardless of whether they're immediate 
> invocations.
this can be relaxed to hasAPValueResult without any change in behavior.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1374
+  emitAbstract(CE->getBeginLoc(), CE->getAPValueResult(), RetType);
+  return Res;
+}

rsmith wrote:
> Can we assert that we succeeded here? This emission should never fail.
from the comment on emitAbstract's declaration it seems to already be the case.
```
  /// Emit the result of the given expression as an abstract constant,
  /// asserting that it succeeded.  This is only safe to do when the
  /// expression is known to be a constant expression with either a fairly
  /// simple type or a known simple form.
  llvm::Constant *emitAbstract(const Expr *E, QualType T);
  llvm::Constant *emitAbstract(SourceLocation loc, const APValue &value,
   QualType T);
``` 



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:464-470
+  QualType RetType = cast(E->getSubExpr()->IgnoreImplicit())
+ ->getCallReturnType(CGF.getContext());
+  if (RetType->isReferenceType()) {
+return CGF.Builder.CreateLoad(Address(
+Result, CGF.getContext().getTypeAlignInChars(
+cast(RetType)->getPointeeType(;
+  }

rsmith wrote:
> OK, so this is presumably handling the case where `ScalarExprEmitter` is used 
> to emit an lvalue expression, under the understanding that when it reaches 
> the eventual lvalue a load will be implicitly generated.
> 
> Looking for a `CallExpr` that returns a reference type is not the best way to 
> handle this. It's brittle (it would break if `tryEmitConstantExpr` starts 
> emitting more kinds of `ConstantExpr` or if we start supporting more kinds of 
> immediate invocations) and we don't need to perform such a subtle check: 
> instead, please just check whether `E` is an lvalue, and perform a load if so.
we need to generate a load for rvalue-reference as well so i think we need to 
check wether E is a glvalue instead of just lvalue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76420



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


[PATCH] D76420: Prevent IR-gen from emitting consteval declarations

2020-05-15 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 264238.
Tyker added a comment.

NFC


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76420

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ConstantEmitter.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCXX/cxx2a-consteval.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++2a -fsyntax-only -Wno-unused-value %s -verify
+// RUN: %clang_cc1 -std=c++2a -emit-llvm-only -Wno-unused-value %s -verify
 
 typedef __SIZE_TYPE__ size_t;
 
Index: clang/test/CodeGenCXX/cxx2a-consteval.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx2a-consteval.cpp
@@ -0,0 +1,212 @@
+// NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+// RUN: %clang_cc1 -emit-llvm %s -std=c++2a -o %t.ll
+// RUN: FileCheck -check-prefix=EVAL -input-file=%t.ll %s
+// RUN: FileCheck -check-prefix=EVAL-FN -input-file=%t.ll %s
+// RUN: FileCheck -check-prefix=EVAL-STATIC -input-file=%t.ll %s
+// RUN: %clang_cc1 -emit-llvm %s -Dconsteval="" -std=c++2a -o %t.ll
+// RUN: FileCheck -check-prefix=EXPR -input-file=%t.ll %s
+
+// there is two version of symbol checks to ensure
+// that the symbol we are looking for are correct
+// EVAL-NOT: @__cxx_global_var_init()
+// EXPR: @__cxx_global_var_init()
+
+// EVAL-NOT: @_Z4ret7v()
+// EXPR: @_Z4ret7v()
+consteval int ret7() {
+  return 7;
+}
+
+int test_ret7() {
+  // EVAL-FN-LABEL: @_Z9test_ret7v(
+  // EVAL-FN-NEXT:  entry:
+  // EVAL-FN-NEXT:[[I:%.*]] = alloca i32, align 4
+  // EVAL-FN-NEXT:store i32 7, i32* [[I]], align 4
+  // EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* [[I]], align 4
+  // EVAL-FN-NEXT:ret i32 [[TMP0]]
+  //
+  int i = ret7();
+  return i;
+}
+
+// EVAL-STATIC: @global_i = global i32 7, align 4
+int global_i = ret7();
+
+// EVAL-STATIC: @_ZL7i_const = internal constant i32 5, align 4
+constexpr int i_const = 5;
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+consteval const int &retI() {
+  return i_const;
+}
+
+const int &test_retRefI() {
+  // EVAL-FN-LABEL: @_Z12test_retRefIv(
+  // EVAL-FN-NEXT:  entry:
+  // EVAL-FN-NEXT:ret i32* @_ZL7i_const
+  //
+  return retI();
+}
+
+int test_retI() {
+  // EVAL-FN-LABEL: @_Z9test_retIv(
+  // EVAL-FN-NEXT:  entry:
+  // EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* @_ZL7i_const, align 4
+  // EVAL-FN-NEXT:ret i32 [[TMP0]]
+  //
+  return retI();
+}
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+consteval const int *retIPtr() {
+  return &i_const;
+}
+
+int test_retIPtr() {
+  // EVAL-FN-LABEL: @_Z12test_retIPtrv(
+  // EVAL-FN-NEXT:  entry:
+  // EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* @_ZL7i_const, align 4
+  // EVAL-FN-NEXT:ret i32 [[TMP0]]
+  //
+  return *retIPtr();
+}
+
+const int *test_retPIPtr() {
+  // EVAL-FN-LABEL: @_Z13test_retPIPtrv(
+  // EVAL-FN-NEXT:  entry:
+  // EVAL-FN-NEXT:ret i32* @_ZL7i_const
+  //
+  return retIPtr();
+}
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+consteval const int &&retIRRef() {
+  return static_cast(i_const);
+}
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+const int &&test_retIRRef() {
+  return static_cast(retIRRef());
+}
+
+int test_retIRRefI() {
+  // EVAL-FN-LABEL: @_Z14test_retIRRefIv(
+  // EVAL-FN-NEXT:  entry:
+  // EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* @_ZL7i_const, align 4
+  // EVAL-FN-NEXT:ret i32 [[TMP0]]
+  //
+  return retIRRef();
+}
+
+struct Agg {
+  int a;
+  long b;
+};
+
+// EVAL-NOT: @_Z6retAggv()
+// EXPR: @_Z6retAggv()
+consteval Agg retAgg() {
+  return {13, 17};
+}
+
+long test_retAgg() {
+  // EVAL-FN-LABEL: @_Z11test_retAggv(
+  // EVAL-FN-NEXT:  entry:
+  // EVAL-FN-NEXT:[[B:%.*]] = alloca i64, align 8
+  // EVAL-FN-NEXT:[[REF_TMP:%.*]] = alloca [[STRUCT_AGG:%.*]], align 8
+  // EVAL-FN-NEXT:[[TMP0:%.*]] = getelementptr inbounds [[STRUCT_AGG]], %struct.Agg* [[REF_TMP]], i32 0, i32 0
+  // EVAL-FN-NEXT:store i32 13, i32* [[TMP0]], align 8
+  // EVAL-FN-NEXT:[[TMP1:%.*]] = getelementptr inbounds [[STRUCT_AGG]], %struct.Agg* [[REF_TMP]], i32 0, i32 1
+  // EVAL-FN-NEXT:store i64 17, i64* [[TMP1]], align 8
+  // EVAL-FN-NEXT:store i64 17, i64* [[B]], align 8
+  // 

[clang] 4db9409 - clang-format: support aligned nested conditionals formatting

2020-05-15 Thread Francois Ferrand via cfe-commits

Author: Francois Ferrand
Date: 2020-05-15T16:38:25+02:00
New Revision: 4db94094b469b4715d08ef37f1799bf3ea7ca8ea

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

LOG: clang-format: support aligned nested conditionals formatting

Summary:
When multiple ternary operators are chained, e.g. like an if/else-if/
else-if/.../else sequence, clang-format will keep aligning the colon
with the question mark, which increases the indent for each
conditionals:

  int a = condition1 ? result1
 : condition2 ? result2
  : condition3 ? result3
   : result4;

This patch detects the situation (e.g. conditionals used in false branch
of another conditional), to avoid indenting in that case:

  int a = condition1 ? result1
: condition2 ? result2
: condition3 ? result3
 : result4;

When BreakBeforeTernaryOperators is false, this will format like this:

  int a = condition1 ? result1 :
  condition2 ? result2 :
  conditino3 ? result3 :
   result4;

This formatting style is referenced here:
https://www.fluentcpp.com/2018/02/27/replace-else-if-ternary-operator/
and here:
https://marcmutz.wordpress.com/2010/10/14/top-5-reasons-you-should-love-your-ternary-operator/

Reviewers: krasimir, djasper, klimek, MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: hokein, dyung, MyDeveloperDay, acoomans, cfe-commits

Tags: #clang, #clang-format

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

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/ContinuationIndenter.h
clang/lib/Format/WhitespaceManager.cpp
clang/lib/Format/WhitespaceManager.h
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index cf885240a4f2..5dc45732ed15 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -367,6 +367,12 @@ bool ContinuationIndenter::mustBreak(const LineState 
&State) {
   State.Stack.back().BreakBeforeParameter && !Current.isTrailingComment() 
&&
   !Current.isOneOf(tok::r_paren, tok::r_brace))
 return true;
+  if (State.Stack.back().IsChainedConditional &&
+  ((Style.BreakBeforeTernaryOperators && Current.is(TT_ConditionalExpr) &&
+Current.is(tok::colon)) ||
+   (!Style.BreakBeforeTernaryOperators && Previous.is(TT_ConditionalExpr) 
&&
+Previous.is(tok::colon
+return true;
   if (((Previous.is(TT_DictLiteral) && Previous.is(tok::l_brace)) ||
(Previous.is(TT_ArrayInitializerLSquare) &&
 Previous.ParameterCount > 1) ||
@@ -1022,8 +1028,23 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState &State) {
   if (State.Stack.back().QuestionColumn != 0 &&
   ((NextNonComment->is(tok::colon) &&
 NextNonComment->is(TT_ConditionalExpr)) ||
-   Previous.is(TT_ConditionalExpr)))
+   Previous.is(TT_ConditionalExpr))) {
+if (((NextNonComment->is(tok::colon) && NextNonComment->Next &&
+  !NextNonComment->Next->FakeLParens.empty() &&
+  NextNonComment->Next->FakeLParens.back() == prec::Conditional) ||
+ (Previous.is(tok::colon) && !Current.FakeLParens.empty() &&
+  Current.FakeLParens.back() == prec::Conditional)) &&
+!State.Stack.back().IsWrappedConditional) {
+  // NOTE: we may tweak this slightly:
+  //* not remove the 'lead' ContinuationIndentWidth
+  //* always un-indent by the operator when
+  //BreakBeforeTernaryOperators=true
+  unsigned Indent =
+  State.Stack.back().Indent - Style.ContinuationIndentWidth;
+  return Indent;
+}
 return State.Stack.back().QuestionColumn;
+  }
   if (Previous.is(tok::comma) && State.Stack.back().VariablePos != 0)
 return State.Stack.back().VariablePos;
   if ((PreviousNonComment &&
@@ -1144,6 +1165,11 @@ unsigned 
ContinuationIndenter::moveStateToNextToken(LineState &State,
   if (Current.is(TT_ArraySubscriptLSquare) &&
   State.Stack.back().StartOfArraySubscripts == 0)
 State.Stack.back().StartOfArraySubscripts = State.Column;
+  if (Current.is(TT_ConditionalExpr) && Current.is(tok::question) &&
+  ((Current.MustBreakBefore) ||
+   (Current.getNextNonComment() &&
+Current.getNextNonComment()->MustBreakBefore)))
+State.Stack.back().IsWrappedConditional = true;
   if (Style.BreakBeforeTernaryOperators && Current.is(tok::question))
 State.Stack.back().QuestionColumn = State.Column;
   if (!Style.BreakBeforeTernaryOperators && Current.isNot(tok::colon)) {
@@ -1284,6 +1310,8 @@ void 
ContinuationIndenter::moveStat

[clang] 0ee04e6 - [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

2020-05-15 Thread Francois Ferrand via cfe-commits

Author: Francois Ferrand
Date: 2020-05-15T16:40:31+02:00
New Revision: 0ee04e6e0d0e1c808dc6c70ff7b92b35f960b627

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

LOG: [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

Summary:
Even when BreakBeforeBinaryOperators is set, AlignOperands kept
aligning the beginning of the line, even when it could align the
actual operands (e.g. after an assignment).

With this patch, the operands are actually aligned, and the operator
gets aligned with the equal sign:

  int a = bb
+ cc;

This not happen in tests, to avoid 'breaking' the indentation:

  if (a
  && b)
return;

Reviewers: krasimir, djasper, klimek, MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: MyDeveloperDay, acoomans, cfe-commits, klimek

Tags: #clang, #clang-format

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/ContinuationIndenter.h
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/FormatTestJS.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 3ea503a592ac..e367c3620e16 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -270,17 +270,49 @@ the configuration (without a prefix: ``Auto``).
 
 
 
-**AlignOperands** (``bool``)
+**AlignOperands** (``OperandAlignmentStyle``)
   If ``true``, horizontally align operands of binary and ternary
   expressions.
 
-  Specifically, this aligns operands of a single expression that needs to be
-  split over multiple lines, e.g.:
+  Possible values:
+
+  * ``OAS_DontAlign`` (in configuration: ``DontAlign``)
+Do not align operands of binary and ternary expressions.
+The wrapped lines are indented ``ContinuationIndentWidth`` spaces from
+the start of the line.
+
+  * ``OAS_Align`` (in configuration: ``Align``)
+Horizontally align operands of binary and ternary expressions.
+
+Specifically, this aligns operands of a single expression that needs
+to be split over multiple lines, e.g.:
+
+.. code-block:: c++
+
+  int aaa = bbb +
+ccc;
+
+When ``BreakBeforeBinaryOperators`` is set, the wrapped operator is
+aligned with the operand on the first line.
+
+.. code-block:: c++
+
+  int aaa = bbb
++ ccc;
+
+  * ``OAS_AlignAfterOperator`` (in configuration: ``AlignAfterOperator``)
+Horizontally align operands of binary and ternary expressions.
+
+This is similar to ``AO_Align``, except when
+``BreakBeforeBinaryOperators`` is set, the operator is un-indented so
+that the wrapped operand is aligned with the operand on the first line.
+
+.. code-block:: c++
+
+  int aaa = bbb
+  + ccc;
 
-  .. code-block:: c++
 
-int aaa = bbb +
-  ccc;
 
 **AlignTrailingComments** (``bool``)
   If ``true``, aligns trailing comments.

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index f8f2903dde57..9bc08a775647 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -153,16 +153,43 @@ struct FormatStyle {
   /// Options for aligning backslashes in escaped newlines.
   EscapedNewlineAlignmentStyle AlignEscapedNewlines;
 
+  /// Different styles for aligning operands.
+  enum OperandAlignmentStyle {
+/// Do not align operands of binary and ternary expressions.
+/// The wrapped lines are indented ``ContinuationIndentWidth`` spaces from
+/// the start of the line.
+OAS_DontAlign,
+/// Horizontally align operands of binary and ternary expressions.
+///
+/// Specifically, this aligns operands of a single expression that needs
+/// to be split over multiple lines, e.g.:
+/// \code
+///   int aaa = bbb +
+/// ccc;
+/// \endcode
+///
+/// When ``BreakBeforeBinaryOperators`` is set, the wrapped operator is
+/// aligned with the operand on the first line.
+/// \code
+///   int aaa = bbb
+/// + ccc;
+/// \endcode
+OAS_Align,
+/// Horizontally align operands of binary and ternary expressions.
+///
+/// This is similar to ``AO_Align``, except when
+/// ``BreakBeforeBinaryOperators`` is set, the operator is un-indented so
+/// that the wrapped operand is aligned with the operand on the first line.
+/// \co

[PATCH] D79903: FastMathFlags.allowContract should be init from FPFeatures.allowFPContractAcrossStatement

2020-05-15 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked an inline comment as done.
mibintc added a subscriber: Anastasia.
mibintc added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2943
+  if (Opts.FastRelaxedMath)
+Opts.setDefaultFPContractMode(LangOptions::FPM_Fast);
   Opts.HexagonQdsp6Compat = Args.hasArg(OPT_mqdsp6_compat);

mibintc wrote:
> rjmccall wrote:
> > michele.scandale wrote:
> > > mibintc wrote:
> > > > mibintc wrote:
> > > > > rjmccall wrote:
> > > > > > mibintc wrote:
> > > > > > > rjmccall wrote:
> > > > > > > > mibintc wrote:
> > > > > > > > > I changed this because the FAST version of this test 
> > > > > > > > > clang/test/CodeGenOpenCL/relaxed-fpmath.cl wants the 'fast' 
> > > > > > > > > attribute on the instruction dump.  All the LLVM FMF bits 
> > > > > > > > > must be set for the fast attribute print.  By default, the 
> > > > > > > > > value for OpenCL is ffp-contract=on
> > > > > > > > Is there an overall behavior change for OpenCL across these 
> > > > > > > > patches?
> > > > > > > I think the answer to your question is no.  Here is more details: 
> > > > > > > OpenCL sets the default behavior to ffp-contract=on.  In 
> > > > > > > https://reviews.llvm.org/D72841 I added the function 
> > > > > > > UpdateFastMathFlags, that function set the llvm FMF.allowContract 
> > > > > > > bit to be ( ffp-contract=on or ffp-contract=fast).  This patch 
> > > > > > > just drops the check on ffp-contract=on.   I didn't wind back to 
> > > > > > > see how the llvm fast attribute was being set for this [opencl] 
> > > > > > > test case originally. 
> > > > > > Well, to what extent are there (including this patch) overall test 
> > > > > > changes for the OpenCL tests, and what are tthey?
> > > > > In the #pragma float_control patch https://reviews.llvm.org/D72841, I 
> > > > > changed 2 CodeGen/OpenCL tests: relaxed-fp-math.cl in the non-FAST 
> > > > > cases to show the contract bit.  Also 1 line in 
> > > > > single-precision-constant.cl for the same reason, to show the 
> > > > > contract bit.  This patch undoes those test changes. I'll do more 
> > > > > investigation to understand why the fast bit isn't being set in the 
> > > > > FAST case in relaxed-fpmath.cl without the change to CompilerInovcaton
> > > > Prior to the patch for #pragma float_control, the llvm.FastMathFlags 
> > > > was initialized from LangArgs.FastMath in the CodeGenFunction 
> > > > constructor approximately line 74, and the FMF values in IRBuilder were 
> > > > never changed--For the test clang/test/CodeGenOpenCL/relaxed-fpmath.cl 
> > > > with option -cl-fast-relaxed-math.  (In ParseLangArgs,  Opts.FastMath = 
> > > > Args.hasArg(OPT_ffast_math) ||  
> > > > Args.hasArg(OPT_cl_fast_relaxed_math))  If FastMath is on, then all the 
> > > > llvm.FMF flags are set.
> > > > 
> > > > The #pragma float_control patch does change the IRBuilder settings in 
> > > > the course of visiting the Expr nodes, using the information in the 
> > > > Expr nodes, but the initial setting of FPFeatures from the command line 
> > > > overlooked the fact that FastMath, and therefore ffp-contract=fast, is 
> > > > enabled. 
> > > Prior to D72841 compiling something with `-ffast-math 
> > > -ffp-contract={on,off}` was still producing `fast` as fast-math flags on 
> > > the instructions for the same reason.
> > > The clang driver does not consider the contraction mode for passing 
> > > `-ffast-math` to CC1, which is consistent with the GCC behavior (I 
> > > checked if the `__FAST_MATH__` is defined if I compile with `-ffast-math 
> > > -ffp-contract=off`).
> > > According to this, the code in `CodeGenFunction`:
> > > ```
> > > if (LangOpts.FastMath)
> > >   FMF.setFast();
> > > ```
> > > is not correct.
> > > 
> > > The OpenCL option `-cl-fast-relaxed-math` should be equivalent to 
> > > `-ffast-math` for the user. I don't know what the interaction between 
> > > `-cl-fast-relaxed-math` and `-ffp-contract={on, off,fast}`.
> > > 
> > > If we need to keep `-cl-fast-relaxed-math` a CC1 option, I guess the 
> > > following might work:
> > > ```
> > > if (Args.hasArg(OPTS_cl_fast_relaxed_math) && 
> > > !Arg.hasArg(OPT_ffp_contractEQ))
> > >   Opts.setDefaultFPContractMode)LangOptions::FPM_Fast);
> > > ```
> > Okay, thanks for the investigation, I agree that that all makes sense.  I'm 
> > not sure what it would mean to enable fast math but disable contraction — 
> > that combination doesn't seem useful.
> > 
> > I'm fine with going forward with the OpenCL changes as they are, but you 
> > might want to specifically reach out to the OpenCL people and let them know 
> > what's going on.
> @arsenm Matt, I'm making this change to CompilerInvocation to fix a bug that 
> was introduced by https://reviews.llvm.org/D72841  I see that you contribute 
> to OpenCL will you please let interested folks know about this change?
> D72841 erroneously set the llvm.FMF.contract bit to true whether the 
> contraction status was "allow 

[PATCH] D79903: FastMathFlags.allowContract should be init from FPFeatures.allowFPContractAcrossStatement

2020-05-15 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 264241.
mibintc marked an inline comment as done.
mibintc added a comment.

This is the same as the previous patch, except I removed the fix for pragma 
push-pop that John said should be committed separately


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79903

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/constrained-math-builtins.c
  clang/test/CodeGen/fp-contract-on-pragma.cpp
  clang/test/CodeGen/fp-contract-pragma.cpp
  clang/test/CodeGen/fp-floatcontrol-class.cpp
  clang/test/CodeGen/fp-floatcontrol-pragma.cpp
  clang/test/CodeGen/fp-floatcontrol-stack.cpp
  clang/test/CodeGenOpenCL/relaxed-fpmath.cl
  clang/test/CodeGenOpenCL/single-precision-constant.cl

Index: clang/test/CodeGenOpenCL/single-precision-constant.cl
===
--- clang/test/CodeGenOpenCL/single-precision-constant.cl
+++ clang/test/CodeGenOpenCL/single-precision-constant.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -cl-single-precision-constant -emit-llvm -o - | FileCheck %s
 
 float fn(float f) {
-  // CHECK: tail call contract float @llvm.fmuladd.f32(float %f, float 2.00e+00, float 1.00e+00)
+  // CHECK: tail call float @llvm.fmuladd.f32(float %f, float 2.00e+00, float 1.00e+00)
   return f*2. + 1.;
 }
Index: clang/test/CodeGenOpenCL/relaxed-fpmath.cl
===
--- clang/test/CodeGenOpenCL/relaxed-fpmath.cl
+++ clang/test/CodeGenOpenCL/relaxed-fpmath.cl
@@ -8,12 +8,12 @@
 float spscalardiv(float a, float b) {
   // CHECK: @spscalardiv(
 
-  // NORMAL: fdiv contract float
+  // NORMAL: fdiv float
   // FAST: fdiv fast float
-  // FINITE: fdiv nnan ninf contract float
-  // UNSAFE: fdiv nnan nsz contract float
-  // MAD: fdiv contract float
-  // NOSIGNED: fdiv nsz contract float
+  // FINITE: fdiv nnan ninf float
+  // UNSAFE: fdiv nnan nsz float
+  // MAD: fdiv float
+  // NOSIGNED: fdiv nsz float
   return a / b;
 }
 // CHECK: attributes
Index: clang/test/CodeGen/fp-floatcontrol-stack.cpp
===
--- clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -9,7 +9,7 @@
 float fun_default FUN(1)
 //CHECK-LABEL: define {{.*}} @_Z11fun_defaultf{{.*}}
 #if DEFAULT
-//CHECK-DDEFAULT: call contract float @llvm.fmuladd{{.*}}
+//CHECK-DDEFAULT: call float @llvm.fmuladd{{.*}}
 #endif
 #if EBSTRICT
 // Note that backend wants constrained intrinsics used
@@ -37,7 +37,7 @@
 //CHECK-DEBSTRICT: llvm.experimental.constrained.fmuladd{{.*}}tonearest{{.*}}strict
 #endif
 #if NOHONOR
-//CHECK-NOHONOR: nnan ninf contract float {{.*}}llvm.experimental.constrained.fmuladd{{.*}}tonearest{{.*}}strict
+//CHECK-NOHONOR: nnan ninf float {{.*}}llvm.experimental.constrained.fmuladd{{.*}}tonearest{{.*}}strict
 #endif
 #if FAST
 //Not possible to enable float_control(except) in FAST mode.
@@ -49,13 +49,13 @@
 float exc_pop FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_popf{{.*}}
 #if DEFAULT
-//CHECK-DDEFAULT: call contract float @llvm.fmuladd{{.*}}
+//CHECK-DDEFAULT: call float @llvm.fmuladd{{.*}}
 #endif
 #if EBSTRICT
 //CHECK-DEBSTRICT: llvm.experimental.constrained.fmuladd{{.*}}tonearest{{.*}}strict
 #endif
 #if NOHONOR
-//CHECK-NOHONOR: call nnan ninf contract float @llvm.fmuladd{{.*}}
+//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
 #endif
 #if FAST
 //CHECK-FAST: fmul fast float
@@ -66,13 +66,13 @@
 float exc_off FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_offf{{.*}}
 #if DEFAULT
-//CHECK-DDEFAULT: call contract float @llvm.fmuladd{{.*}}
+//CHECK-DDEFAULT: call float @llvm.fmuladd{{.*}}
 #endif
 #if EBSTRICT
-//CHECK-DEBSTRICT: call contract float @llvm.fmuladd{{.*}}
+//CHECK-DEBSTRICT: call float @llvm.fmuladd{{.*}}
 #endif
 #if NOHONOR
-//CHECK-NOHONOR: call nnan ninf contract float @llvm.fmuladd{{.*}}
+//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
 #endif
 #if FAST
 //CHECK-FAST: fmul fast float
@@ -83,30 +83,30 @@
 float precise_on FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z10precise_onf{{.*}}
 #if DEFAULT
-//CHECK-DDEFAULT: contract float {{.*}}llvm.fmuladd{{.*}}
+//CHECK-DDEFAULT: float {{.*}}llvm.fmuladd{{.*}}
 #endif
 #if EBSTRICT
-//CHECK-DEBSTRICT: contract float {{.*}}llvm.fmuladd{{.*}}
+//CHECK-DEBSTRICT: float {{.*}}llvm.fmuladd{{.*}}
 #endif
 #if NOHONOR
 // If precise is pushed then all fast-math should be off!
-//CHECK-NOHONOR: call contract float {{.*}}llvm.fmuladd{{.*}}
+//CHECK-NOHONOR: call float {{.*}}llvm.fmuladd{{.*}}
 #endif
 #if FAST
-//CHECK-FAST: contract float {{.*}}llvm.fmuladd{{.*}}
+//CHECK-FAST: float {{.*}}llvm.fmuladd{{.*}}
 #endif
 
 #pragma float_control(pop)
 float precise_pop FUN(3)
 //CHECK-LABEL: define {{.*}} @_Z11precise_popf{{.*}}

[PATCH] D80003: [clang][clang-scan-deps] Add a mode that can compute overhead in duplicated module builds (Patch series 3/3)

2020-05-15 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 264243.
dang added a comment.

Updating D80003 : [clang][clang-scan-deps] Add 
a mode that can compute overhead in duplicated module builds (Patch series 3/3)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80003

Files:
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -6,12 +6,14 @@
 //
 //===--===//
 
+#include "clang/Basic/Module.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/InitLLVM.h"
@@ -20,6 +22,7 @@
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 
@@ -165,6 +168,13 @@
 llvm::cl::init(false),
 llvm::cl::cat(DependencyScannerCategory));
 
+llvm::cl::opt GatherMetrics(
+"metrics", llvm::cl::Optional,
+llvm::cl::desc(
+"Gather metrics during tool operation to measure overhead of modules "
+"built in explicit mode with respect to implicit modules."),
+llvm::cl::init(false), llvm::cl::cat(DependencyScannerCategory));
+
 } // end anonymous namespace
 
 /// \returns object-file path derived from source-file path.
@@ -327,6 +337,65 @@
 OS << llvm::formatv("{0:2}\n", Value(std::move(Output)));
   }
 
+  void computeAndPrintBuildMetrics(raw_ostream &OS) {
+std::unordered_map
+RelaxedHashesEfficiencyInfo;
+std::set UniqueModuleSignatures;
+for (auto &&M : Modules) {
+  std::string RelaxedHashModule =
+  M.second.ModuleName + '-' + M.second.RelaxedContextHash;
+  auto &BuiltModulesInfo = RelaxedHashesEfficiencyInfo[RelaxedHashModule];
+  BuiltModulesInfo.BuiltModules.push_back(&M.second);
+  auto InsertionResult =
+  UniqueModuleSignatures.insert(M.second.ModuleSignature);
+  if (InsertionResult.second)
+BuiltModulesInfo.UniqueASTFileSignatures++;
+}
+
+size_t TotalStrictContextHashModules = Modules.size();
+size_t TotalRelaxedHashModules = RelaxedHashesEfficiencyInfo.size();
+auto PercentageModuleNumberIncrease =
+100 * ((TotalStrictContextHashModules - TotalRelaxedHashModules) /
+   TotalRelaxedHashModules);
+
+OS << "Total relaxed hash modules: " << TotalRelaxedHashModules << "\n";
+OS << "Total unique AST signatures: " << UniqueModuleSignatures.size()
+   << "\n";
+OS << "Total strict context hash modules: " << TotalStrictContextHashModules
+   << "\n";
+OS << "Module number increase: " << PercentageModuleNumberIncrease
+   << "%\n\n";
+
+OS << "Details:\n";
+for (auto &&It : RelaxedHashesEfficiencyInfo) {
+  auto &Duplicates = It.second.BuiltModules;
+  size_t NumDuplicates = Duplicates.size();
+
+  assert(NumDuplicates > 0 && "Cannot have a relaxed hash module that "
+  "doesn't map to at least a strict"
+  "one!");
+
+  if (NumDuplicates > 1) {
+OS << "Relaxed hash module: " << It.first << " gets duplicated as ("
+   << It.second.UniqueASTFileSignatures << "/" << NumDuplicates
+   << ") modules:\n\n";
+
+auto OutputModuleDep = [](raw_ostream &OS, ModuleDeps *MD) {
+  OS << MD->ModuleName << "-" << MD->ContextHash;
+};
+
+auto DuplicatesIt = Duplicates.begin();
+OutputModuleDep(OS, *DuplicatesIt);
+++DuplicatesIt;
+for (auto End = Duplicates.end(); DuplicatesIt != End; ++DuplicatesIt) {
+  OS << "; ";
+  OutputModuleDep(OS, *DuplicatesIt);
+}
+OS << "\n\n";
+  }
+}
+  }
+
 private:
   StringRef lookupPCMPath(ClangModuleDep CMD) {
 return Modules[ContextModulePair{CMD.ContextHash, CMD.ModuleName, 0}]
@@ -340,6 +409,11 @@
 return I->second;
   };
 
+  struct BuiltModulesEfficiencyInfo {
+std::vector BuiltModules;
+size_t UniqueASTFileSignatures;
+ 

[PATCH] D79903: FastMathFlags.allowContract should be init from FPFeatures.allowFPContractAcrossStatement

2020-05-15 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a subscriber: arsenm.
mibintc added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2943
+  if (Opts.FastRelaxedMath)
+Opts.setDefaultFPContractMode(LangOptions::FPM_Fast);
   Opts.HexagonQdsp6Compat = Args.hasArg(OPT_mqdsp6_compat);

rjmccall wrote:
> michele.scandale wrote:
> > mibintc wrote:
> > > mibintc wrote:
> > > > rjmccall wrote:
> > > > > mibintc wrote:
> > > > > > rjmccall wrote:
> > > > > > > mibintc wrote:
> > > > > > > > I changed this because the FAST version of this test 
> > > > > > > > clang/test/CodeGenOpenCL/relaxed-fpmath.cl wants the 'fast' 
> > > > > > > > attribute on the instruction dump.  All the LLVM FMF bits must 
> > > > > > > > be set for the fast attribute print.  By default, the value for 
> > > > > > > > OpenCL is ffp-contract=on
> > > > > > > Is there an overall behavior change for OpenCL across these 
> > > > > > > patches?
> > > > > > I think the answer to your question is no.  Here is more details: 
> > > > > > OpenCL sets the default behavior to ffp-contract=on.  In 
> > > > > > https://reviews.llvm.org/D72841 I added the function 
> > > > > > UpdateFastMathFlags, that function set the llvm FMF.allowContract 
> > > > > > bit to be ( ffp-contract=on or ffp-contract=fast).  This patch just 
> > > > > > drops the check on ffp-contract=on.   I didn't wind back to see how 
> > > > > > the llvm fast attribute was being set for this [opencl] test case 
> > > > > > originally. 
> > > > > Well, to what extent are there (including this patch) overall test 
> > > > > changes for the OpenCL tests, and what are tthey?
> > > > In the #pragma float_control patch https://reviews.llvm.org/D72841, I 
> > > > changed 2 CodeGen/OpenCL tests: relaxed-fp-math.cl in the non-FAST 
> > > > cases to show the contract bit.  Also 1 line in 
> > > > single-precision-constant.cl for the same reason, to show the contract 
> > > > bit.  This patch undoes those test changes. I'll do more investigation 
> > > > to understand why the fast bit isn't being set in the FAST case in 
> > > > relaxed-fpmath.cl without the change to CompilerInovcaton
> > > Prior to the patch for #pragma float_control, the llvm.FastMathFlags was 
> > > initialized from LangArgs.FastMath in the CodeGenFunction constructor 
> > > approximately line 74, and the FMF values in IRBuilder were never 
> > > changed--For the test clang/test/CodeGenOpenCL/relaxed-fpmath.cl with 
> > > option -cl-fast-relaxed-math.  (In ParseLangArgs,  Opts.FastMath = 
> > > Args.hasArg(OPT_ffast_math) ||  
> > > Args.hasArg(OPT_cl_fast_relaxed_math))  If FastMath is on, then all the 
> > > llvm.FMF flags are set.
> > > 
> > > The #pragma float_control patch does change the IRBuilder settings in the 
> > > course of visiting the Expr nodes, using the information in the Expr 
> > > nodes, but the initial setting of FPFeatures from the command line 
> > > overlooked the fact that FastMath, and therefore ffp-contract=fast, is 
> > > enabled. 
> > Prior to D72841 compiling something with `-ffast-math 
> > -ffp-contract={on,off}` was still producing `fast` as fast-math flags on 
> > the instructions for the same reason.
> > The clang driver does not consider the contraction mode for passing 
> > `-ffast-math` to CC1, which is consistent with the GCC behavior (I checked 
> > if the `__FAST_MATH__` is defined if I compile with `-ffast-math 
> > -ffp-contract=off`).
> > According to this, the code in `CodeGenFunction`:
> > ```
> > if (LangOpts.FastMath)
> >   FMF.setFast();
> > ```
> > is not correct.
> > 
> > The OpenCL option `-cl-fast-relaxed-math` should be equivalent to 
> > `-ffast-math` for the user. I don't know what the interaction between 
> > `-cl-fast-relaxed-math` and `-ffp-contract={on, off,fast}`.
> > 
> > If we need to keep `-cl-fast-relaxed-math` a CC1 option, I guess the 
> > following might work:
> > ```
> > if (Args.hasArg(OPTS_cl_fast_relaxed_math) && 
> > !Arg.hasArg(OPT_ffp_contractEQ))
> >   Opts.setDefaultFPContractMode)LangOptions::FPM_Fast);
> > ```
> Okay, thanks for the investigation, I agree that that all makes sense.  I'm 
> not sure what it would mean to enable fast math but disable contraction — 
> that combination doesn't seem useful.
> 
> I'm fine with going forward with the OpenCL changes as they are, but you 
> might want to specifically reach out to the OpenCL people and let them know 
> what's going on.
@arsenm Matt, I'm making this change to CompilerInvocation to fix a bug that 
was introduced by https://reviews.llvm.org/D72841  I see that you contribute to 
OpenCL will you please let interested folks know about this change?
D72841 erroneously set the llvm.FMF.contract bit to true whether the 
contraction status was "allow contraction across statements" or "allow 
contraction within statements".  This patch corrects that error to set 
llvm.FMF.contract bit only when contraction status is "allow contraction across 
statements".  D72841 mis-captur

[PATCH] D50078: clang-format: support aligned nested conditionals formatting

2020-05-15 Thread Francois Ferrand via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4db94094b469: clang-format: support aligned nested 
conditionals formatting (authored by Typz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D50078

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/ContinuationIndenter.h
  clang/lib/Format/WhitespaceManager.cpp
  clang/lib/Format/WhitespaceManager.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5975,6 +5975,124 @@
" // comment\n"
" ? a = b\n"
" : a;");
+
+  // Chained conditionals
+  FormatStyle Style = getLLVMStyle();
+  Style.ColumnLimit = 70;
+  Style.AlignOperands = true;
+  verifyFormat("return  ? \n"
+   "   : bb ? \n"
+   ": ;",
+   Style);
+  verifyFormat("return  ? \n"
+   "   : bb ? \n"
+   ": ;",
+   Style);
+  verifyFormat("return aa ? \n"
+   "   :  ? \n"
+   "  : ;",
+   Style);
+  verifyFormat("return  ? \n"
+   "   : bb ? 22\n"
+   ": 33;",
+   Style);
+  verifyFormat("return  ? \n"
+   "   : bb ? \n"
+   "   : cc ? \n"
+   ": ;",
+   Style);
+  verifyFormat("return  ? (aaa ? bbb : ccc)\n"
+   "   : bb ? \n"
+   ": ;",
+   Style);
+  verifyFormat("return  ? \n"
+   "   : bb ? \n"
+   ": (aaa ? bbb : ccc);",
+   Style);
+  verifyFormat(
+  "return  ? (a ? bb\n"
+  " : cc)\n"
+  "   : bb ? \n"
+  ": ;",
+  Style);
+  verifyFormat(
+  "return a? (a ? bb\n"
+  " : cc)\n"
+  "   : bb ? \n"
+  ": ;",
+  Style);
+  verifyFormat(
+  "return a? a = (a ? bb\n"
+  " : dd)\n"
+  "   : bb ? \n"
+  ": ;",
+  Style);
+  verifyFormat(
+  "return a? a + (a ? bb\n"
+  " : dd)\n"
+  "   : bb ? \n"
+  ": ;",
+  Style);
+  verifyFormat(
+  "return a? \n"
+  "   : bb ? \n"
+  ": a + (a ? bb\n"
+  " : dd)\n",
+  Style);
+  verifyFormat(
+  "return  ? \n"
+  "   : bb ? \n"
+  ": (a ? bb\n"
+  " : cc);",
+  Style);
+  verifyFormat(
+  "return  ? (a ? bb\n"
+  "   : ccc ? dd\n"
+  " : ee)\n"
+  "   : bb ? \n"
+  ": ;",
+  Style);
+  verifyFormat(
+  "return  ? (aa? bb\n"
+  "   : ccc ? dd\n"
+  " : ee)\n"
+  "   : 

[PATCH] D80014: Turn -Wmax-tokens off by default

2020-05-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.
hans added a reviewer: thakis.
Herald added a project: clang.

On the one hand, one might interpret the use of the max-token pragmas or 
-fmax-tokens flag as an opt-in to the warning. However, in Chromium we've found 
it useful to only opt in selected build configurations, even though we have the 
pragmas in the code. For that reason, we think it makes sense to turn it off by 
default.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80014

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/test/Parser/max-tokens.cpp


Index: clang/test/Parser/max-tokens.cpp
===
--- clang/test/Parser/max-tokens.cpp
+++ clang/test/Parser/max-tokens.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS  
-fmax-tokens=2
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS_OVERRIDE 
-fmax-tokens=9
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wmax-tokens
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wmax-tokens -DMAX_TOKENS  
-fmax-tokens=2
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wmax-tokens -DMAX_TOKENS_OVERRIDE 
-fmax-tokens=9
 
 int x, y, z;
 
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1428,11 +1428,11 @@
 
 def warn_max_tokens : Warning<
   "the number of preprocessor source tokens (%0) exceeds this token limit 
(%1)">,
-  InGroup;
+  InGroup, DefaultIgnore;
 
 def warn_max_tokens_total : Warning<
   "the total number of preprocessor source tokens (%0) exceeds the token limit 
(%1)">,
-  InGroup;
+  InGroup, DefaultIgnore;
 
 def note_max_tokens_total_override : Note<"total token limit set here">;
 
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1202,5 +1202,8 @@
 These limits can be helpful in limiting code growth through included files.
 
 Setting a token limit of zero means no limit.
+
+Note that the warning is disabled by default, so -Wmax-tokens must be used
+in addition with the pragmas or -fmax-tokens flag to get any warnings.
 }];
 }


Index: clang/test/Parser/max-tokens.cpp
===
--- clang/test/Parser/max-tokens.cpp
+++ clang/test/Parser/max-tokens.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS  -fmax-tokens=2
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS_OVERRIDE -fmax-tokens=9
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wmax-tokens
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wmax-tokens -DMAX_TOKENS  -fmax-tokens=2
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wmax-tokens -DMAX_TOKENS_OVERRIDE -fmax-tokens=9
 
 int x, y, z;
 
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1428,11 +1428,11 @@
 
 def warn_max_tokens : Warning<
   "the number of preprocessor source tokens (%0) exceeds this token limit (%1)">,
-  InGroup;
+  InGroup, DefaultIgnore;
 
 def warn_max_tokens_total : Warning<
   "the total number of preprocessor source tokens (%0) exceeds the token limit (%1)">,
-  InGroup;
+  InGroup, DefaultIgnore;
 
 def note_max_tokens_total_override : Note<"total token limit set here">;
 
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1202,5 +1202,8 @@
 These limits can be helpful in limiting code growth through included files.
 
 Setting a token limit of zero means no limit.
+
+Note that the warning is disabled by default, so -Wmax-tokens must be used
+in addition with the pragmas or -fmax-tokens flag to get any warnings.
 }];
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74572: [BPF] preserve debuginfo types for builtin __builtin__btf_type_id()

2020-05-15 Thread Yonghong Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b01b465388b: [BPF] preserve debuginfo types for builtin 
__builtin__btf_type_id() (authored by yonghong-song).

Changed prior to commit:
  https://reviews.llvm.org/D74572?vs=262140&id=264256#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74572

Files:
  llvm/lib/Target/BPF/BPF.h
  llvm/lib/Target/BPF/BPFCORE.h
  llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp
  llvm/lib/Target/BPF/BPFPreserveDIType.cpp
  llvm/lib/Target/BPF/BPFTargetMachine.cpp
  llvm/lib/Target/BPF/BTFDebug.cpp
  llvm/lib/Target/BPF/BTFDebug.h
  llvm/lib/Target/BPF/CMakeLists.txt
  llvm/test/CodeGen/BPF/BTF/builtin-btf-type-id.ll

Index: llvm/test/CodeGen/BPF/BTF/builtin-btf-type-id.ll
===
--- /dev/null
+++ llvm/test/CodeGen/BPF/BTF/builtin-btf-type-id.ll
@@ -0,0 +1,148 @@
+; RUN: llc -march=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
+; RUN: llc -march=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
+; RUN: llc -march=bpfel -mattr=+alu32 -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
+; RUN: llc -march=bpfeb -mattr=+alu32 -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
+;
+; Source code:
+;   static int (*bpf_log)(unsigned tid, void *data, int data_size) = (void *)999;
+;   struct {
+; char f1[100];
+; typeof(3) f2;
+;   } tmp__abc = {1, 3};
+;   void prog1() {
+; bpf_log(__builtin_btf_type_id(tmp__abc, 0), &tmp__abc, sizeof(tmp__abc));
+;   }
+;   void prog2() {
+; bpf_log(__builtin_btf_type_id(&tmp__abc, 1), &tmp__abc, sizeof(tmp__abc));
+;   }
+;   void prog3() {
+; bpf_log(__builtin_btf_type_id(tmp__abc.f1[3], 1), &tmp__abc, sizeof(tmp__abc));
+;   }
+; Compilation flag:
+;   clang -target bpf -O2 -g -S -emit-llvm test.c
+
+%struct.anon = type { [100 x i8], i32 }
+
+@tmp__abc = dso_local global { <{ i8, i8, [98 x i8] }>, i32 } { <{ i8, i8, [98 x i8] }> <{ i8 1, i8 3, [98 x i8] zeroinitializer }>, i32 0 }, align 4, !dbg !0
+
+; Function Attrs: nounwind
+define dso_local void @prog1() local_unnamed_addr #0 !dbg !28 {
+entry:
+  %0 = tail call i32 @llvm.bpf.btf.type.id.p0s_struct.anons.i32(%struct.anon* bitcast ({ <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc to %struct.anon*), i32 1, i64 0), !dbg !31, !llvm.preserve.access.index !7
+  %call = tail call i32 inttoptr (i64 999 to i32 (i32, i8*, i32)*)(i32 %0, i8* getelementptr inbounds ({ <{ i8, i8, [98 x i8] }>, i32 }, { <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc, i64 0, i32 0, i32 0), i32 104) #2, !dbg !32
+  ret void, !dbg !33
+}
+
+; Function Attrs: nounwind readnone
+declare i32 @llvm.bpf.btf.type.id.p0s_struct.anons.i32(%struct.anon*, i32, i64) #1
+
+; Function Attrs: nounwind
+define dso_local void @prog2() local_unnamed_addr #0 !dbg !34 {
+entry:
+  %0 = tail call i32 @llvm.bpf.btf.type.id.p0s_struct.anons.i32(%struct.anon* bitcast ({ <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc to %struct.anon*), i32 0, i64 1), !dbg !35, !llvm.preserve.access.index !6
+  %call = tail call i32 inttoptr (i64 999 to i32 (i32, i8*, i32)*)(i32 %0, i8* getelementptr inbounds ({ <{ i8, i8, [98 x i8] }>, i32 }, { <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc, i64 0, i32 0, i32 0), i32 104) #2, !dbg !36
+  ret void, !dbg !37
+}
+
+; Function Attrs: nounwind
+define dso_local void @prog3() local_unnamed_addr #0 !dbg !38 {
+entry:
+  %0 = tail call i32 @llvm.bpf.btf.type.id.p0i8.i32(i8* getelementptr inbounds ({ <{ i8, i8, [98 x i8] }>, i32 }, { <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc, i64 0, i32 0, i32 2, i64 1), i32 1, i64 1), !dbg !39, !llvm.preserve.access.index !11
+  %call = tail call i32 inttoptr (i64 999 to i32 (i32, i8*, i32)*)(i32 %0, i8* getelementptr inbounds ({ <{ i8, i8, [98 x i8] }>, i32 }, { <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc, i64 0, i32 0, i32 0), i32 104) #2, !dbg !40
+  ret void, !dbg !41
+}
+
+; CHECK-LABEL:   prog1
+; CHECK: r1 = 3
+; CHECK-LABEL:   prog2
+; CHECK: r1 = 10
+; CHECK-LABEL:   prog3
+; CHECK: r1 = 4
+;
+; CHECK: .long   0   # BTF_KIND_STRUCT(id = 3)
+; CHECK-NEXT:.long   67108866# 0x402
+; CHECK-NEXT:.long   104
+; CHECK-NEXT:.long   13
+; CHECK-NEXT:.long   5
+; CHECK-NEXT:.long   0   # 0x0
+; CHECK-NEXT:.long   16
+; CHECK-NEXT:.long   7
+; CHECK-NEXT:.long   800 # 0x320
+; CHECK-NEXT:.long   19  # BTF_KIND_INT(id = 4)
+; CHECK-NEXT:.long   16777216# 0x100
+; CHECK-NEXT:.long   1
+; CHECK-NEXT:.long   16777224# 0x108
+; CHECK: .long   0   # BTF_KIND_PTR(id = 10)
+; CHECK-NEXT:.long   33554432# 0x200
+; CHECK-NEXT:.long   3
+
+; CHECK: .long   16  # FieldR

[PATCH] D80015: [Analyzer][StreamChecker] Added support for 'fread' and 'fwrite'.

2020-05-15 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, ASDenysPetrov, martong, Charusso, 
gamesh411, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a project: clang.

Stream functions `fread` and `fwrite` are evaluated
and preconditions checked.
A new bug type is added for a (non fatal) warning if `fread`
is called in EOF state.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80015

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-error.c

Index: clang/test/Analysis/stream-error.c
===
--- clang/test/Analysis/stream-error.c
+++ clang/test/Analysis/stream-error.c
@@ -7,6 +7,7 @@
 #include "Inputs/system-header-simulator.h"
 
 void clang_analyzer_eval(int);
+void clang_analyzer_warnIfReached();
 void StreamTesterChecker_make_feof_stream(FILE *);
 void StreamTesterChecker_make_ferror_stream(FILE *);
 
@@ -57,6 +58,84 @@
   fclose(F);
 }
 
+void error_fread() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  char Buf[10];
+  int Ret = fread(Buf, 1, 10, F);
+  if (Ret == 10) {
+clang_analyzer_eval(feof(F) || ferror(F)); // expected-warning {{FALSE}}
+  } else {
+clang_analyzer_eval(feof(F) || ferror(F)); // expected-warning {{TRUE}}
+if (feof(F)) {
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+  fread(Buf, 1, 10, F);   // expected-warning {{Read function called when stream is in EOF state}}
+  clang_analyzer_eval(feof(F));   // expected-warning {{TRUE}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+}
+if (ferror(F)) {
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+  fread(Buf, 1, 10, F);   // no warning
+}
+  }
+  fclose(F);
+  Ret = fread(Buf, 1, 10, F); // expected-warning {{Stream might be already closed}}
+}
+
+void error_fwrite() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  const char *Buf = "123456789";
+  int Ret = fwrite(Buf, 1, 10, F);
+  if (Ret == 10) {
+clang_analyzer_eval(feof(F) || ferror(F)); // expected-warning {{FALSE}}
+  } else {
+clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+clang_analyzer_eval(ferror(F)); // expected-warning {{TRUE}}
+fwrite(0, 1, 10, F);// no warning
+  }
+  fclose(F);
+  Ret = fwrite(0, 1, 10, F); // expected-warning {{Stream might be already closed}}
+}
+
+void freadwrite_zerosize(FILE *F) {
+  fwrite(0, 1, 0, F);
+  fwrite(0, 0, 1, F);
+  fread(0, 1, 0, F);
+  fread(0, 0, 1, F);
+}
+
+void freadwrite_zerosize_eofstate(FILE *F) {
+  fwrite(0, 1, 0, F);
+  fwrite(0, 0, 1, F);
+  fread(0, 1, 0, F); // expected-warning {{Read function called when stream is in EOF state}}
+  fread(0, 0, 1, F); // expected-warning {{Read function called when stream is in EOF state}}
+}
+
+void error_fread_fwrite_zerosize() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+
+  freadwrite_zerosize(F);
+  clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+
+  StreamTesterChecker_make_ferror_stream(F);
+  freadwrite_zerosize(F);
+  clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{TRUE}}
+
+  StreamTesterChecker_make_feof_stream(F);
+  freadwrite_zerosize_eofstate(F);
+  clang_analyzer_eval(feof(F));   // expected-warning {{TRUE}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+
+  fclose(F);
+}
+
 void error_fseek() {
   FILE *F = fopen("file", "r");
   if (!F)
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -52,6 +52,10 @@
 return NoError == ES.NoError && FEof == ES.FEof && FError == ES.FError;
   }
 
+  bool operator!=(const StreamErrorState &ES) const {
+return NoError != ES.NoError || FEof != ES.FEof || FError != ES.FError;
+  }
+
   StreamErrorState operator|(const StreamErrorState &E) const {
 return {NoError || E.NoError, FEof || E.FEof, FError || E.FError};
   }
@@ -172,7 +176,7 @@
 class StreamChecker
 : public Checker {
   mutable std::unique_ptr BT_nullfp, BT_illegalwhence,
-  BT_UseAfterClose, BT_UseAfterOpenFailed, BT_ResourceLeak;
+  BT_UseAfterClose, BT_UseAfterOpenFailed, BT_ResourceLeak, BT_StreamEof;
 
 public:
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
@@ -190,8 +194,12 @@
   {{"tmpfile"}, {nullptr, &StreamChecker::evalFopen, ArgNone}},
   {{"fclose", 1},
{&StreamChecker::preDefault, &StreamChecker::evalFclose, 0}},
-  {{"fread", 4}, {&StreamChecker::preDefault, nullptr, 3}},
-  {{"fwrite", 4}, {&StreamChecker::preDefault, 

[PATCH] D80016: [analyzer] StdLibraryFunctionsChecker: Add support to lookup types

2020-05-15 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: xazax.hun, NoQ, Szelethus, balazske.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, 
gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
baloghadamsoftware, whisperity.
Herald added a project: clang.

In this patch I am trying to get rid of the `Irrelevant` types from the
signatures of the functions from the standard C library. For that I've
introduced `lookupType()` to be able to lookup arbitrary types in the global
scope. This makes it possible to define the signatures precisely.

Note 1) `fread`'s signature is now fixed to have the proper `FILE *restrict`
type when C99 is the language.
Note 2) There are still existing `Irrelevant` types, but they are all from
POSIX. I am planning to address those together with the missing POSIX functions
(in D79433 ).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80016

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions-lookup.c
  clang/test/Analysis/std-c-library-functions-lookup.cpp
  clang/test/Analysis/std-c-library-functions.c

Index: clang/test/Analysis/std-c-library-functions.c
===
--- clang/test/Analysis/std-c-library-functions.c
+++ clang/test/Analysis/std-c-library-functions.c
@@ -53,10 +53,10 @@
 // CHECK-NEXT: Loaded summary for: int getc(FILE *)
 // CHECK-NEXT: Loaded summary for: int fgetc(FILE *)
 // CHECK-NEXT: Loaded summary for: int getchar()
+// CHECK-NEXT: Loaded summary for: unsigned int fread(void *restrict, size_t, size_t, FILE *restrict)
+// CHECK-NEXT: Loaded summary for: unsigned int fwrite(const void *restrict, size_t, size_t, FILE *restrict)
 // CHECK-NEXT: Loaded summary for: ssize_t read(int, void *, size_t)
 // CHECK-NEXT: Loaded summary for: ssize_t write(int, const void *, size_t)
-// CHECK-NEXT: Loaded summary for: unsigned int fread(void *restrict, size_t, size_t, FILE *)
-// CHECK-NEXT: Loaded summary for: unsigned int fwrite(const void *restrict, size_t, size_t, FILE *restrict)
 // CHECK-NEXT: Loaded summary for: ssize_t getline(char **, size_t *, FILE *)
 
 void clang_analyzer_eval(int);
@@ -104,7 +104,7 @@
   }
 }
 
-size_t fread(void *restrict, size_t, size_t, FILE *);
+size_t fread(void *restrict, size_t, size_t, FILE *restrict);
 size_t fwrite(const void *restrict, size_t, size_t, FILE *restrict);
 void test_fread_fwrite(FILE *fp, int *buf) {
 
Index: clang/test/Analysis/std-c-library-functions-lookup.cpp
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-lookup.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple i686-unknown-linux 2>&1 | FileCheck %s
+
+//  CHECK: Loaded summary for: size_t fread(void *, size_t, size_t, FILE *)
+//  CHECK-NOT: Loaded summary for: size_t fread(void *, size_t, size_t, MyFile *)
+
+typedef unsigned int size_t;
+typedef struct FILE FILE;
+size_t fread(void *, size_t, size_t, FILE *);
+
+struct MyFile;
+size_t fread(void *, size_t, size_t, MyFile *);
+
+// Must have at least one call expression to initialize the summary map.
+int bar(void);
+void foo() {
+  bar();
+}
Index: clang/test/Analysis/std-c-library-functions-lookup.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-lookup.c
@@ -0,0 +1,19 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple i686-unknown-linux 2>&1 | FileCheck %s
+
+// CHECK: Loaded summary for: unsigned int fread(void *restrict, size_t, size_t, FILE *restrict)
+
+typedef typeof(sizeof(int)) size_t;
+typedef struct FILE FILE;
+size_t fread(void *restrict, size_t, size_t, FILE *restrict);
+
+// Must have at least one call expression to initialize the summary map.
+int bar(void);
+void foo() {
+  bar();
+}
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -64,7 +64,7 @@
 
 typedef struct FILE FILE;
 typedef typeof(sizeof(int)) size_t;
-size_t frea

[PATCH] D79895: Fix warning about using uninitialized variable as function const reference parameter

2020-05-15 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

The summary of this change should be "add warning..." not "fix warning..."

Could you add more detail into the commit description? About newly introduced 
diagnostic groups, etc.

Also, I thought I saw tests in a previous revision but now they seem to be gone?


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

https://reviews.llvm.org/D79895



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


[PATCH] D79465: [clang-format] Fix line lengths w/ comments in align

2020-05-15 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD updated this revision to Diff 264259.
JakeMerdichAMD added a comment.

Add a comment explaining why checking IsInsideToken is needed here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79465

Files:
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11564,6 +11564,16 @@
"  x = 1;\n"
"y = 1;\n",
Alignment);
+
+  Alignment.ReflowComments = true;
+  Alignment.ColumnLimit = 50;
+  EXPECT_EQ("int x   = 0;\n"
+"int yy  = 1; /// specificlennospace\n"
+"int zzz = 2;\n",
+format("int x   = 0;\n"
+   "int yy  = 1; ///specificlennospace\n"
+   "int zzz = 2;\n",
+   Alignment));
 }
 
 TEST_F(FormatTest, AlignConsecutiveDeclarations) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -410,8 +410,16 @@
 
 unsigned ChangeMinColumn = Changes[i].StartOfTokenColumn;
 int LineLengthAfter = -Changes[i].Spaces;
-for (unsigned j = i; j != e && Changes[j].NewlinesBefore == 0; ++j)
-  LineLengthAfter += Changes[j].Spaces + Changes[j].TokenLength;
+for (unsigned j = i; j != e && Changes[j].NewlinesBefore == 0; ++j) {
+  LineLengthAfter += Changes[j].Spaces;
+  // Changes are generally 1:1 with the tokens, but a change could also be
+  // inside of a token, in which case it's counted more than once: once for
+  // the whitespace surrounding the token (!IsInsideToken) and once for
+  // each whitespace change within it (IsInsideToken).
+  // Therefore, changes inside of a token should only count the space.
+  if (!Changes[j].IsInsideToken)
+LineLengthAfter += Changes[j].TokenLength;
+}
 unsigned ChangeMaxColumn = Style.ColumnLimit - LineLengthAfter;
 
 // If we are restricted by the maximum column width, end the sequence.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11564,6 +11564,16 @@
"  x = 1;\n"
"y = 1;\n",
Alignment);
+
+  Alignment.ReflowComments = true;
+  Alignment.ColumnLimit = 50;
+  EXPECT_EQ("int x   = 0;\n"
+"int yy  = 1; /// specificlennospace\n"
+"int zzz = 2;\n",
+format("int x   = 0;\n"
+   "int yy  = 1; ///specificlennospace\n"
+   "int zzz = 2;\n",
+   Alignment));
 }
 
 TEST_F(FormatTest, AlignConsecutiveDeclarations) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -410,8 +410,16 @@
 
 unsigned ChangeMinColumn = Changes[i].StartOfTokenColumn;
 int LineLengthAfter = -Changes[i].Spaces;
-for (unsigned j = i; j != e && Changes[j].NewlinesBefore == 0; ++j)
-  LineLengthAfter += Changes[j].Spaces + Changes[j].TokenLength;
+for (unsigned j = i; j != e && Changes[j].NewlinesBefore == 0; ++j) {
+  LineLengthAfter += Changes[j].Spaces;
+  // Changes are generally 1:1 with the tokens, but a change could also be
+  // inside of a token, in which case it's counted more than once: once for
+  // the whitespace surrounding the token (!IsInsideToken) and once for
+  // each whitespace change within it (IsInsideToken).
+  // Therefore, changes inside of a token should only count the space.
+  if (!Changes[j].IsInsideToken)
+LineLengthAfter += Changes[j].TokenLength;
+}
 unsigned ChangeMaxColumn = Style.ColumnLimit - LineLengthAfter;
 
 // If we are restricted by the maximum column width, end the sequence.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78508: [Clang] Allow long as size_t printf argument on 32-bit Windows platforms.

2020-05-15 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

I'll re-iterate my opinion that the casts currently required to bypass the 
warnings are useful (e.g., if you ever want to port the code to 64-bit).  There 
are lots of places where the Windows API essentially required uncomfortable 
conversions, and we can't paper over all of them.  The way to get it right in 
all those other places is to be very aware of the underlying types.  Hiding an 
uncomfortable detail here and there seems like a disservice.




Comment at: clang/lib/AST/FormatString.cpp:407
+if ((isSizeT() || isPtrdiffT()) &&
+C.getTargetInfo().getTriple().isOSMSVCRT() &&
+C.getTargetInfo().getTriple().isArch32Bit())

I'm not convinced `isOSMSVCRT` is the right check.  The troubling typedefs are 
[[ 
https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types#size-t
 | `SIZE_T` and `SSIZE_T` ]], which come from the Windows API and are unrelated 
to Microsoft's C run-time library.  I think `isOSWindows` would be more precise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78508



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


[PATCH] D79754: [OpenMP][AMDGCN] Support OpenMP offloading for AMDGCN architecture - Part 1

2020-05-15 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds added inline comments.



Comment at: clang/include/clang/Basic/TargetInfo.h:1261
+  /// Currently only supports NVPTX and AMDGCN
+  static bool isOpenMPGPU(llvm::Triple &T) {
+return T.isNVPTX() || T.isAMDGCN();

How is "OpenMP-compatible GPU" defined? I think it's too early to start 
designing predicates about whether a target is a GPU and whether it supports 
OpenMP.



Comment at: clang/lib/AST/Decl.cpp:3221
+!hasAttr()) ||
+   Context.getTargetInfo().getTriple().isAMDGCN()) &&
   !(BuiltinID == Builtin::BIprintf || BuiltinID == Builtin::BImalloc))

This seems awkward to me. Why mix it up with only CUDA and HIP? The earlier 
factoring is better, where CUDA/HIP took care of their own business, and the 
catch-all case of AMDGCN was a separate clause by itself. It doesn't matter 
that the builtins being checked for AMDGCN on OpenMP are //currently// 
identical to CUDA/HIP. When this situation later changes (I am sure OpenMP will 
support more builtins), we will have to split it out again anyway.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3100
 
+  bool IsOpenMPGPU = clang::TargetInfo::isOpenMPGPU(T);
+

I am not particularly in favour of introducing a variable just because it looks 
smaller than a call at each appropriate location. If you really want it this 
way, at least make it a const.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3104
   // handling code for those requiring so.
-  if ((Opts.OpenMPIsDevice && T.isNVPTX()) || Opts.OpenCLCPlusPlus) {
+  if ((Opts.OpenMPIsDevice && IsOpenMPGPU) || Opts.OpenCLCPlusPlus) {
 Opts.Exceptions = 0;

Looking at the comment before this line, the correct predicate would "target 
supports exceptions with OpenMP". Is it always true that every GPU that 
supports OpenMP will not support exception handling? I would recommend just 
checking individual targets for now instead of inventing predicates.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3157
+  // Set CUDA mode for OpenMP target NVPTX/AMDGCN if specified in options
+  Opts.OpenMPCUDAMode = Opts.OpenMPIsDevice && IsOpenMPGPU &&
 Args.hasArg(options::OPT_fopenmp_cuda_mode);

Is there any reason to believe that every future GPU added to this predicate 
will also want the CUDA mode set? I would recommend using individual targets 
for now instead of inventing a new predicate.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3162
   Opts.OpenMPCUDAForceFullRuntime =
-  Opts.OpenMPIsDevice && T.isNVPTX() &&
+  Opts.OpenMPIsDevice && IsOpenMPGPU &&
   Args.hasArg(options::OPT_fopenmp_cuda_force_full_runtime);

Same doubt about this use of an artificial predicate as commented earlier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79754



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


[PATCH] D79322: [FEnv] Small fixes to implementation of flt.rounds

2020-05-15 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff marked an inline comment as done.
sepavloff added inline comments.



Comment at: llvm/test/CodeGen/RISCV/flt-rounds.ll:23
+; RV64I-NEXT:sd ra, 8(sp)
+; RV64I-NEXT:call __flt_rounds
+; RV64I-NEXT:ld ra, 8(sp)

lenary wrote:
> I'm interested to understand how this function is provided. Is it part of 
> `compiler-rt` or `libgcc`, or is it provided another way?
At least musl library provides its implementation: 
https://git.musl-libc.org/cgit/musl/tree/src/fenv/__flt_rounds.c . Similar 
implementation exists in glibc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79322



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


[PATCH] D78508: [Clang] Allow long as size_t printf argument on 32-bit Windows platforms.

2020-05-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D78508#2038793 , @amccarth wrote:

> I'll re-iterate my opinion that the casts currently required to bypass the 
> warnings are useful (e.g., if you ever want to port the code to 64-bit).  
> There are lots of places where the Windows API essentially required 
> uncomfortable conversions, and we can't paper over all of them.  The way to 
> get it right in all those other places is to be very aware of the underlying 
> types.  Hiding an uncomfortable detail here and there seems like a disservice.


+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78508



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


[PATCH] D80018: [Analyzer][StreamChecker] Added check for "indeterminate file position".

2020-05-15 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, ASDenysPetrov, martong, Charusso, 
gamesh411, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a project: clang.

According to the standard, after a `wread` or `fwrite` call the file position
becomes "indeterminate". It is assumable that a next read or write causes
undefined behavior, so a (fatal error) warning is added for this case.
The indeterminate position can be cleared by some operations, for example
`fseek` or `freopen`, not with `clearerr`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80018

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-error.c

Index: clang/test/Analysis/stream-error.c
===
--- clang/test/Analysis/stream-error.c
+++ clang/test/Analysis/stream-error.c
@@ -76,7 +76,7 @@
 }
 if (ferror(F)) {
   clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
-  fread(Buf, 1, 10, F);   // no warning
+  fread(Buf, 1, 10, F);   // expected-warning {{might be 'indeterminate'}}
 }
   }
   fclose(F);
@@ -94,7 +94,7 @@
   } else {
 clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
 clang_analyzer_eval(ferror(F)); // expected-warning {{TRUE}}
-fwrite(0, 1, 10, F);// no warning
+fwrite(0, 1, 10, F);// expected-warning {{might be 'indeterminate'}}
   }
   fclose(F);
   Ret = fwrite(0, 1, 10, F); // expected-warning {{Stream might be already closed}}
@@ -166,3 +166,36 @@
   }
   fclose(F);
 }
+
+void error_fseek_indeterminate() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  const char *Buf = "123456789";
+  int rc = fseek(F, 0, SEEK_SET);
+  if (rc) {
+if (feof(F)) {
+  fwrite(Buf, 1, 10, F); // no warning
+} else if (ferror(F)) {
+  fwrite(Buf, 1, 10, F); // expected-warning {{might be 'indeterminate'}}
+} else {
+  fwrite(Buf, 1, 10, F); // expected-warning {{might be 'indeterminate'}}
+}
+  }
+  fclose(F);
+}
+
+void error_clearerr_indeterminate() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  const char *Buf = "123456789";
+  int rc = fseek(F, 0, SEEK_SET);
+  if (rc) {
+if (!feof(F)) {
+  clearerr(F);
+  fwrite(Buf, 1, 10, F); // expected-warning {{might be 'indeterminate'}}
+}
+  }
+  fclose(F);
+}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -97,6 +97,16 @@
   /// Ignored in non-opened stream state but must be NoError.
   StreamErrorState ErrorState;
 
+  /// Indicate if the file has an "indeterminate file position indicator".
+  /// This can be set at a failing read or write or seek operation.
+  /// If it is set no more read or write is allowed.
+  /// This value is not dependent on the stream error flags:
+  /// The error flag may be cleared with `clearerr` but the file position
+  /// remains still indeterminate.
+  /// This value applies to all error states in ErrorState except FEOF.
+  /// An EOF+indeterminate state is the same as EOF state.
+  bool FilePositionIndeterminate = false;
+
   bool isOpened() const { return State == Opened; }
   bool isClosed() const { return State == Closed; }
   bool isOpenFailed() const { return State == OpenFailed; }
@@ -105,12 +115,14 @@
 // In not opened state error state should always NoError, so comparison
 // here is no problem.
 return LastOperation == X.LastOperation && State == X.State &&
-   ErrorState == X.ErrorState;
+   ErrorState == X.ErrorState &&
+   FilePositionIndeterminate == X.FilePositionIndeterminate;
   }
 
   static StreamState getOpened(const FnDescription *L,
-   const StreamErrorState &ES = {}) {
-return StreamState{L, Opened, ES};
+   const StreamErrorState &ES = ErrorNone,
+   bool FPI = false) {
+return StreamState{L, Opened, ES, FPI};
   }
   static StreamState getClosed(const FnDescription *L) {
 return StreamState{L, Closed};
@@ -123,6 +135,7 @@
 ID.AddPointer(LastOperation);
 ID.AddInteger(State);
 ID.AddInteger(ErrorState);
+ID.AddBoolean(FilePositionIndeterminate);
   }
 };
 
@@ -176,7 +189,8 @@
 class StreamChecker
 : public Checker {
   mutable std::unique_ptr BT_nullfp, BT_illegalwhence,
-  BT_UseAfterClose, BT_UseAfterOpenFailed, BT_ResourceLeak, BT_StreamEof;
+  BT_UseAfterClose, BT_UseAfterOpenFailed, BT_ResourceLeak, BT_StreamEof,
+  BT_IndeterminatePosition;
 
 public:
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
@@ -282,6 +296,16 @@
   ProgramStateRef ensureStreamOpened

[clang] 072cde0 - [Clang][BPF] implement __builtin_btf_type_id() builtin function

2020-05-15 Thread Yonghong Song via cfe-commits

Author: Yonghong Song
Date: 2020-05-15T09:44:54-07:00
New Revision: 072cde03aaa13a2c57acf62d79876bf79aa1919f

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

LOG: [Clang][BPF] implement __builtin_btf_type_id() builtin function

Such a builtin function is mostly useful to preserve btf type id
for non-global data. For example,
   extern void foo(..., void *data, int size);
   int test(...) {
 struct t { int a; int b; int c; } d;
 d.a = ...; d.b = ...; d.c = ...;
 foo(..., &d, sizeof(d));
   }

The function "foo" in the above only see raw data and does not
know what type of the data is. In certain cases, e.g., logging,
the additional type information will help pretty print.

This patch implemented a BPF specific builtin
  u32 btf_type_id = __builtin_btf_type_id(param, flag)
which will return a btf type id for the "param".
flag == 0 will indicate a BTF local relocation,
which means btf type_id only adjusted when bpf program BTF changes.
flag == 1 will indicate a BTF remote relocation,
which means btf type_id is adjusted against linux kernel or
future other entities.

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

Added: 
clang/test/CodeGen/builtin-bpf-btf-type-id.c
clang/test/Sema/builtin-bpf-btf-type-id.c

Modified: 
clang/include/clang/Basic/BuiltinsBPF.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
llvm/include/llvm/IR/IntrinsicsBPF.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsBPF.def 
b/clang/include/clang/Basic/BuiltinsBPF.def
index bd96b9ef531b..237e9dc8784b 100644
--- a/clang/include/clang/Basic/BuiltinsBPF.def
+++ b/clang/include/clang/Basic/BuiltinsBPF.def
@@ -20,5 +20,8 @@
 // Get record field information.
 TARGET_BUILTIN(__builtin_preserve_field_info, "Ui.", "t", "")
 
+// Get BTF type id.
+TARGET_BUILTIN(__builtin_btf_type_id, "Ui.", "t", "")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 371e20183e1e..0fe8b1e6abfc 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10749,6 +10749,8 @@ def err_preserve_field_info_not_field : Error<
   "__builtin_preserve_field_info argument %0 not a field access">;
 def err_preserve_field_info_not_const: Error<
   "__builtin_preserve_field_info argument %0 not a constant">;
+def err_btf_type_id_not_const: Error<
+  "__builtin_btf_type_id argument %0 not a constant">;
 
 def err_bit_cast_non_trivially_copyable : Error<
   "__builtin_bit_cast %select{source|destination}0 type must be trivially 
copyable">;

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 5166f91e252c..524924e36638 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10633,33 +10633,103 @@ Value 
*CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
 
 Value *CodeGenFunction::EmitBPFBuiltinExpr(unsigned BuiltinID,
const CallExpr *E) {
-  assert(BuiltinID == BPF::BI__builtin_preserve_field_info &&
- "unexpected ARM builtin");
+  assert((BuiltinID == BPF::BI__builtin_preserve_field_info ||
+  BuiltinID == BPF::BI__builtin_btf_type_id) &&
+ "unexpected BPF builtin");
 
-  const Expr *Arg = E->getArg(0);
-  bool IsBitField = Arg->IgnoreParens()->getObjectKind() == OK_BitField;
+  switch (BuiltinID) {
+  default:
+llvm_unreachable("Unexpected BPF builtin");
+  case BPF::BI__builtin_preserve_field_info: {
+const Expr *Arg = E->getArg(0);
+bool IsBitField = Arg->IgnoreParens()->getObjectKind() == OK_BitField;
 
-  if (!getDebugInfo()) {
-CGM.Error(E->getExprLoc(), "using builtin_preserve_field_info() without 
-g");
-return IsBitField ? EmitLValue(Arg).getBitFieldPointer()
-  : EmitLValue(Arg).getPointer(*this);
-  }
+if (!getDebugInfo()) {
+  CGM.Error(E->getExprLoc(),
+"using __builtin_preserve_field_info() without -g");
+  return IsBitField ? EmitLValue(Arg).getBitFieldPointer()
+: EmitLValue(Arg).getPointer(*this);
+}
+
+// Enable underlying preserve_*_access_index() generation.
+bool OldIsInPreservedAIRegion = IsInPreservedAIRegion;
+IsInPreservedAIRegion = true;
+Value *FieldAddr = IsBitField ? EmitLValue(Arg).getBitFieldPointer()
+  : EmitLValue(Arg).getPointer(*this);
+IsInPreservedAIRegion = OldIsInPreservedAIRegion;
+
+ConstantInt *C = cast(EmitScalarExpr(E->getArg(1)));
+Value *InfoKind = ConstantInt::get(Int64Ty, C->getSExtValue());
+
+// Built the IR for 

[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-05-15 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 264266.
cchen added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79972

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_codegen.cpp

Index: clang/test/OpenMP/target_update_codegen.cpp
===
--- clang/test/OpenMP/target_update_codegen.cpp
+++ clang/test/OpenMP/target_update_codegen.cpp
@@ -1059,5 +1059,142 @@
   #pragma omp target update from(([sa][5])f)
 }
 
+#endif
+
+///==///
+// RUN: %clang_cc1 -DCK19 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK19 --check-prefix CK19-64
+// RUN: %clang_cc1 -DCK19 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK19 --check-prefix CK19-64
+// RUN: %clang_cc1 -DCK19 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK19 --check-prefix CK19-32
+// RUN: %clang_cc1 -DCK19 -fopenmp -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK19 --check-prefix CK19-32
+
+// RUN: %clang_cc1 -DCK19 -verify -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY19 %s
+// RUN: %clang_cc1 -DCK19 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY19 %s
+// RUN: %clang_cc1 -DCK19 -verify -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY19 %s
+// RUN: %clang_cc1 -DCK19 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY19 %s
+// SIMD-ONLY19-NOT: {{__kmpc|__tgt}}
+#ifdef CK19
+
+// CK19: [[STRUCT_DESCRIPTOR:%.+]]  = type { i64, i64, i64 }
+
+// CK19: [[MSIZE:@.+]] = {{.+}}constant [1 x i64] [i64 3]
+// CK19: [[MTYPE:@.+]] = {{.+}}constant [1 x i64] [i64 2081]
+
+// CK19-LABEL: _Z3foo
+void foo(int arg) {
+  int arr[3][4][5];
+
+  // CK19: [[DIMS:%.+]] = alloca [3 x [[STRUCT_DESCRIPTOR]]],
+  // CK19: [[ARRAY_IDX:%.+]] = getelementptr inbounds [3 x [4 x [5 x i32]]], [3 x [4 x [5 x i32]]]* [[ARR:%.+]], {{.+}} 0, {{.+}} 0
+  // CK19: [[ARRAY_DECAY:%.+]] = getelementptr inbounds [4 x [5 x i32]], [4 x [5 x i32]]* [[ARRAY_IDX]], {{.+}} 0, {{.+}} 0
+  // CK19: [[ARRAY_IDX_1:%.+]] = getelementptr inbounds [5 x i32], [5 x i32]* [[ARRAY_DECAY]], {{.+}}
+  // CK19: [[ARRAY_DECAY_2:%.+]] = getelementptr inbounds [5 x i32], [5 x i32]* [[ARRAY_IDX_1]], {{.+}} 0, {{.+}} 0
+  // CK19: [[ARRAY_IDX_3:%.+]] = getelementptr inbounds {{.+}}, {{.+}}* [[ARRAY_DECAY_2]], {{.+}} 1
+  // CK19: [[LEN:%.+]] = sub nuw i64 4, [[ARG_ADDR:%.+]]
+  // CK19: [[BP0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BP:%.+]], i{{.+}} 0, i{{.+}} 0
+  // CK19: [[P0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[P:%.+]], i{{.+}} 0, i{{.+}} 0
+  // CK19: [[DIM_1:%.+]] = getelementptr inbounds [3 x [[STRUCT_DESCRIPTOR]]], [3 x [[STRUCT_DESCRIPTOR]]]* [[DIMS]], {{.+}} 0, {{.+}} 0
+  // CK19: [[OFFSET:%.+]] = getelementptr inbounds [[STRUCT_DESCRIPTOR]], [[STRUCT_DESCRIPTOR]]* [[DIM_1]], {{.+}} 0, {{.+}} 0
+  // CK19: store i64 0, i64* [[OFFSET]],
+  // CK19: [[COUNT:%.+]] = getelementptr inbounds

[PATCH] D78374: [Analyzer][StreamChecker] Added evaluation of fread and fwrite.

2020-05-15 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Created new revisions for parts of this change and a bit improved: D80009 
 and others in "Stack".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78374



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


[PATCH] D74668: [Clang][BPF] implement __builtin_btf_type_id() builtin function

2020-05-15 Thread Yonghong Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG072cde03aaa1: [Clang][BPF] implement __builtin_btf_type_id() 
builtin function (authored by yonghong-song).

Changed prior to commit:
  https://reviews.llvm.org/D74668?vs=261976&id=264273#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74668

Files:
  clang/include/clang/Basic/BuiltinsBPF.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-bpf-btf-type-id.c
  clang/test/Sema/builtin-bpf-btf-type-id.c
  llvm/include/llvm/IR/IntrinsicsBPF.td

Index: llvm/include/llvm/IR/IntrinsicsBPF.td
===
--- llvm/include/llvm/IR/IntrinsicsBPF.td
+++ llvm/include/llvm/IR/IntrinsicsBPF.td
@@ -23,4 +23,7 @@
   def int_bpf_preserve_field_info : GCCBuiltin<"__builtin_bpf_preserve_field_info">,
   Intrinsic<[llvm_i32_ty], [llvm_anyptr_ty, llvm_i64_ty],
   [IntrNoMem, ImmArg<1>]>;
+  def int_bpf_btf_type_id : GCCBuiltin<"__builtin_bpf_btf_type_id">,
+  Intrinsic<[llvm_i32_ty], [llvm_any_ty, llvm_any_ty, llvm_i64_ty],
+  [IntrNoMem]>;
 }
Index: clang/test/Sema/builtin-bpf-btf-type-id.c
===
--- /dev/null
+++ clang/test/Sema/builtin-bpf-btf-type-id.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x c -triple bpf-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
+
+struct {
+  char f1[100];
+  int f2;
+} tmp = {};
+
+unsigned invalid1() { return __builtin_btf_type_id(1, tmp); } // expected-error {{__builtin_btf_type_id argument 2 not a constant}}
+unsigned invalid2() { return __builtin_btf_type_id(1, 1, 1); } // expected-error {{too many arguments to function call, expected 2, have 3}}
+
+int valid1() { return __builtin_btf_type_id(tmp, 0); }
+int valid2() { return __builtin_btf_type_id(&tmp, 1); }
+int valid3() { return __builtin_btf_type_id(tmp.f1[4], 10); }
Index: clang/test/CodeGen/builtin-bpf-btf-type-id.c
===
--- /dev/null
+++ clang/test/CodeGen/builtin-bpf-btf-type-id.c
@@ -0,0 +1,13 @@
+// REQUIRES: bpf-registered-target
+// RUN: %clang -target bpf -emit-llvm -S -g %s -o - | FileCheck %s
+
+unsigned test1(int a) { return __builtin_btf_type_id(a, 0); }
+unsigned test2(int a) { return __builtin_btf_type_id(&a, 0); }
+
+// CHECK: define dso_local i32 @test1
+// CHECK: call i32 @llvm.bpf.btf.type.id.p0i32.i32(i32* %{{[0-9a-z.]+}}, i32 1, i64 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[INT:[0-9]+]]
+// CHECK: define dso_local i32 @test2
+// CHECK: call i32 @llvm.bpf.btf.type.id.p0i32.i32(i32* %{{[0-9a-z.]+}}, i32 0, i64 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[INT_POINTER:[0-9]+]]
+//
+// CHECK: ![[INT]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed
+// CHECK: ![[INT_POINTER]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[INT]], size: 64
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -2487,17 +2487,33 @@
 
 bool Sema::CheckBPFBuiltinFunctionCall(unsigned BuiltinID,
CallExpr *TheCall) {
-  assert(BuiltinID == BPF::BI__builtin_preserve_field_info &&
+  assert((BuiltinID == BPF::BI__builtin_preserve_field_info ||
+  BuiltinID == BPF::BI__builtin_btf_type_id) &&
  "unexpected ARM builtin");
 
   if (checkArgCount(*this, TheCall, 2))
 return true;
 
+  Expr *Arg;
+  if (BuiltinID == BPF::BI__builtin_btf_type_id) {
+// The second argument needs to be a constant int
+llvm::APSInt Value;
+Arg = TheCall->getArg(1);
+if (!Arg->isIntegerConstantExpr(Value, Context)) {
+  Diag(Arg->getBeginLoc(), diag::err_btf_type_id_not_const)
+  << 2 << Arg->getSourceRange();
+  return true;
+}
+
+TheCall->setType(Context.UnsignedIntTy);
+return false;
+  }
+
   // The first argument needs to be a record field access.
   // If it is an array element access, we delay decision
   // to BPF backend to check whether the access is a
   // field access or not.
-  Expr *Arg = TheCall->getArg(0);
+  Arg = TheCall->getArg(0);
   if (Arg->getType()->getAsPlaceholderType() ||
   (Arg->IgnoreParens()->getObjectKind() != OK_BitField &&
!dyn_cast(Arg->IgnoreParens()) &&
@@ -2508,8 +2524,9 @@
   }
 
   // The second argument needs to be a constant int
+  Arg = TheCall->getArg(1);
   llvm::APSInt Value;
-  if (!TheCall->getArg(1)->isIntegerConstantExpr(Value, Context)) {
+  if (!Arg->isIntegerConstantExpr(Value, Context)) {
 Diag(Arg->getBeginLoc(), diag::err_preserve_field_info_not_const)
 << 2 << Arg->getSourceRange();
 return true;
Index: clang/lib/Code

[clang] f89f7da - [IR] Convert null-pointer-is-valid into an enum attribute

2020-05-15 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2020-05-15T19:41:07+02:00
New Revision: f89f7da999f362e4213c69923328dd1033276e59

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

LOG: [IR] Convert null-pointer-is-valid into an enum attribute

The "null-pointer-is-valid" attribute needs to be checked by many
pointer-related combines. To make the check more efficient, convert
it from a string into an enum attribute.

In the future, this attribute may be replaced with data layout
properties.

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGen/delete-null-pointer-checks.c
llvm/docs/LangRef.rst
llvm/include/llvm/Bitcode/LLVMBitCodes.h
llvm/include/llvm/IR/Attributes.td
llvm/include/llvm/IR/AutoUpgrade.h
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/AsmParser/LLToken.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/IR/Attributes.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/IR/Function.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/test/Analysis/MemorySSA/cyclicphi.ll
llvm/test/Analysis/ValueTracking/assume.ll
llvm/test/Bitcode/attributes.ll
llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
llvm/test/Transforms/Attributor/align.ll
llvm/test/Transforms/Attributor/nocapture-1.ll
llvm/test/Transforms/Attributor/nonnull.ll
llvm/test/Transforms/Attributor/norecurse.ll
llvm/test/Transforms/Attributor/undefined_behavior.ll
llvm/test/Transforms/CorrelatedValuePropagation/non-null.ll
llvm/test/Transforms/FunctionAttrs/nocapture.ll
llvm/test/Transforms/FunctionAttrs/nonnull.ll
llvm/test/Transforms/GVN/PRE/2018-06-08-pre-load-dbgloc-no-null-opt.ll
llvm/test/Transforms/GlobalOpt/MallocSROA-section-no-null-opt.ll
llvm/test/Transforms/GlobalOpt/heap-sra-1-no-null-opt.ll
llvm/test/Transforms/GlobalOpt/heap-sra-1.ll
llvm/test/Transforms/GlobalOpt/heap-sra-2-no-null-opt.ll
llvm/test/Transforms/GlobalOpt/heap-sra-2.ll
llvm/test/Transforms/GlobalOpt/heap-sra-3-no-null-opt.ll
llvm/test/Transforms/GlobalOpt/heap-sra-3.ll
llvm/test/Transforms/GlobalOpt/heap-sra-4-no-null-opt.ll
llvm/test/Transforms/GlobalOpt/heap-sra-4.ll
llvm/test/Transforms/GlobalOpt/heap-sra-phi-no-null-opt.ll
llvm/test/Transforms/GlobalOpt/heap-sra-phi.ll
llvm/test/Transforms/GlobalOpt/load-store-global-no-null-opt.ll
llvm/test/Transforms/GlobalOpt/malloc-promote-1-no-null-opt.ll
llvm/test/Transforms/GlobalOpt/malloc-promote-1.ll
llvm/test/Transforms/GlobalOpt/malloc-promote-2-no-null-opt.ll
llvm/test/Transforms/GlobalOpt/malloc-promote-2.ll
llvm/test/Transforms/GlobalOpt/storepointer-compare-no-null-opt.ll
llvm/test/Transforms/GlobalOpt/storepointer-no-null-opt.ll
llvm/test/Transforms/IPConstantProp/PR26044.ll
llvm/test/Transforms/Inline/attributes.ll
llvm/test/Transforms/InstCombine/atomic.ll
llvm/test/Transforms/InstCombine/invariant.group.ll
llvm/test/Transforms/InstCombine/invoke.ll
llvm/test/Transforms/InstCombine/lifetime-no-null-opt.ll
llvm/test/Transforms/InstCombine/load.ll
llvm/test/Transforms/InstCombine/mem-deref-bytes.ll
llvm/test/Transforms/InstCombine/memchr.ll
llvm/test/Transforms/InstCombine/memcpy-addrspace.ll
llvm/test/Transforms/InstCombine/memcpy-from-global.ll
llvm/test/Transforms/InstCombine/memrchr.ll
llvm/test/Transforms/InstCombine/select.ll
llvm/test/Transforms/InstCombine/store.ll
llvm/test/Transforms/InstCombine/strchr-1.ll
llvm/test/Transforms/InstCombine/strcpy_chk-64.ll
llvm/test/Transforms/InstCombine/strlen-1.ll
llvm/test/Transforms/InstCombine/strncat-2.ll
llvm/test/Transforms/InstCombine/strncmp-1.ll
llvm/test/Transforms/InstCombine/strrchr-1.ll
llvm/test/Transforms/InstCombine/strstr-1.ll
llvm/test/Transforms/InstCombine/wcslen-1.ll
llvm/test/Transforms/InstSimplify/compare.ll
llvm/test/Transforms/LoopIdiom/pr28196.ll
llvm/test/Transforms/LoopVersioning/lcssa.ll
llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
llvm/test/Transforms/SimplifyCFG/invoke.ll
llvm/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll
llvm/test/Transforms/SimplifyCFG/trap-no-null-opt-debugloc.ll
llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
llvm/test/Transforms/Util/assume-builder.ll
mlir/test/Target/llvmir.mlir

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 32a9ba499ecb..068d053d17cc 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1744,7 +1744,7 @@ void CodeG

[PATCH] D78508: [Clang] Allow long as size_t printf argument on 32-bit Windows platforms.

2020-05-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

> clang issues a warning, leaving no good way to print SIZE_T (other than 
> disabling warnings or adding useless casts)

I also don't think Clang should change here though. The warning is legit for 
code that cares about portability, and inserting a cast is probably the best 
fix for such code. For code that doesn't care, disabling the warning seems like 
the way to go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78508



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


[PATCH] D80020: [PowerPC] Add support for -mcpu=pwr10 in the front end

2020-05-15 Thread Lei Huang via Phabricator via cfe-commits
lei created this revision.
lei added reviewers: stefanp, nemanjai, amyk, hfinkel, power-llvm-team.
Herald added subscribers: shchenz, wuzish.
Herald added a project: clang.
jsji added a reviewer: PowerPC.
jsji added a project: PowerPC.

This patch simply adds support for the new CPU in anticipation of
Power10. There isn't really any functionality added so there are no
associated test cases at this time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80020

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Driver/ToolChains/Arch/PPC.cpp
  clang/test/Misc/target-invalid-cpu-note.c
  clang/test/Preprocessor/init-ppc64.c

Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -627,6 +627,22 @@
 // PPCPOWER9:#define _ARCH_PWR7 1
 // PPCPOWER9:#define _ARCH_PWR9 1
 //
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr10 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPOWER10 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power10 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPOWER10 %s
+//
+// PPCPOWER10:#define _ARCH_PPC 1
+// PPCPOWER10:#define _ARCH_PPC64 1
+// PPCPOWER10:#define _ARCH_PPCGR 1
+// PPCPOWER10:#define _ARCH_PPCSQ 1
+// PPCPOWER10:#define _ARCH_PWR10 1
+// PPCPOWER10:#define _ARCH_PWR4 1
+// PPCPOWER10:#define _ARCH_PWR5 1
+// PPCPOWER10:#define _ARCH_PWR5X 1
+// PPCPOWER10:#define _ARCH_PWR6 1
+// PPCPOWER10-NOT:#define _ARCH_PWR6X 1
+// PPCPOWER10:#define _ARCH_PWR7 1
+// PPCPOWER10:#define _ARCH_PWR9 1
+//
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu future -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCFUTURE %s
 //
 // PPCFUTURE:#define _ARCH_PPC 1
Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -81,7 +81,7 @@
 // PPC-SAME: 603e, 603ev, 604, 604e, 620, 630, g3, 7400, g4, 7450, g4+, 750,
 // PPC-SAME: 8548, 970, g5, a2, a2q, e500, e500mc, e5500, power3, pwr3, power4,
 // PPC-SAME: pwr4, power5, pwr5, power5x, pwr5x, power6, pwr6, power6x, pwr6x,
-// PPC-SAME: power7, pwr7, power8, pwr8, power9, pwr9, powerpc, ppc, powerpc64,
+// PPC-SAME: power7, pwr7, power8, pwr8, power9, pwr9, power10, pwr10, powerpc, ppc, powerpc64,
 // PPC-SAME: ppc64, powerpc64le, ppc64le, future
 
 // RUN: not %clang_cc1 -triple mips--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix MIPS
Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp
===
--- clang/lib/Driver/ToolChains/Arch/PPC.cpp
+++ clang/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -70,6 +70,7 @@
 .Case("power7", "pwr7")
 .Case("power8", "pwr8")
 .Case("power9", "pwr9")
+.Case("power10", "pwr10")
 .Case("future", "future")
 .Case("pwr3", "pwr3")
 .Case("pwr4", "pwr4")
@@ -80,6 +81,7 @@
 .Case("pwr7", "pwr7")
 .Case("pwr8", "pwr8")
 .Case("pwr9", "pwr9")
+.Case("pwr10", "pwr10")
 .Case("powerpc", "ppc")
 .Case("powerpc64", "ppc64")
 .Case("powerpc64le", "ppc64le")
@@ -91,14 +93,16 @@
 
 const char *ppc::getPPCAsmModeForCPU(StringRef Name) {
   return llvm::StringSwitch(Name)
-.Case("pwr7", "-mpower7")
-.Case("power7", "-mpower7")
-.Case("pwr8", "-mpower8")
-.Case("power8", "-mpower8")
-.Case("ppc64le", "-mpower8")
-.Case("pwr9", "-mpower9")
-.Case("power9", "-mpower9")
-.Default("-many");
+  .Case("pwr7", "-mpower7")
+  .Case("power7", "-mpower7")
+  .Case("pwr8", "-mpower8")
+  .Case("power8", "-mpower8")
+  .Case("ppc64le", "-mpower8")
+  .Case("pwr9", "-mpower9")
+  .Case("power9", "-mpower9")
+  .Case("pwr10", "-mpower10")
+  .Case("power10", "-mpower10")
+  .Default("-many");
 }
 
 void ppc::getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple,
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -43,13 +43,13 @@
 ArchDefinePwr7 = 1 << 11,
 ArchDefinePwr8 = 1 << 12,
 ArchDefinePwr9 = 1 << 13,
-ArchDefineFuture = 1 << 14,
-ArchDefineA2 = 1 << 15,
-ArchDefineA2q = 1 << 16,
-ArchDefineE500 = 1 << 17
+ArchDefinePwr10 = 1 << 14,
+ArchDefineFuture = 1 << 15,
+ArchDefineA2 = 1 << 16,
+ArchDefineA2q = 1 << 17,
+ArchDefineE500 = 1 << 18
   } ArchDefineTypes;
 
-
   ArchDefineTypes ArchDefs = ArchDefineNone;
   static const Builtin::Info BuiltinInfo

[PATCH] D79995: [clang] [MinGW] Fix libunwind extension

2020-05-15 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a reviewer: rnk.
mstorsjo added a subscriber: rnk.
mstorsjo added a comment.

So, using `-l:libunwind.dll.a` is definitely more correct than 
`-l:libunwind.so` on this platform, so in that sense this is good.

In my toolchains I don't use this option at all so far, because I have 
libunwind bundled into libc++.a/libc++.dll.a, but I guess it would be nice to 
move towards this setup and stop bundling them. But the toolchains can be 
configured to omit either the shared or the static version of the libraries, 
and if libunwind only exists in static form, this would fail.

If there's only a shared version, and building with `-static-libgcc`, I guess 
it's ok to look for explicitly `libunwind.a` and fail in that case, but for the 
default case, I think the normal library resolution logic would be best, i.e. 
just doing `-lunwind`.

The ideal version from my point of view would be this:

  case ToolChain::UNW_CompilerRT:
if (LGT == LibGccType::StaticLibGcc)
  CmdArgs.push_back("-l:libunwind.a");
else if (TC.getTriple().isOSCygMing()) {
  if (LGT == LibGccType::SharedLibGcc)
CmdArgs.push_back("-l:libunwind.dll.a");
  else
CmdArgs.push_back("-lunwind"); // Let the linker choose between 
libunwind.dll.a and libunwind.a depending on what's available, and depending on 
the -static flag
} else
  CmdArgs.push_back("-l:libunwind.so");
break;

That's rather different than the other, non-mingw cases though, but I'm not 
familiar with the reasoning behind those.

Adding @rnk if he'd happen to have opinions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79995



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


[PATCH] D78862: [IR] Convert null-pointer-is-valid into an enum attribute

2020-05-15 Thread Nikita Popov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf89f7da999f3: [IR] Convert null-pointer-is-valid into an 
enum attribute (authored by nikic).

Changed prior to commit:
  https://reviews.llvm.org/D78862?vs=261375&id=264285#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78862

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/delete-null-pointer-checks.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/include/llvm/IR/AutoUpgrade.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Analysis/MemorySSA/cyclicphi.ll
  llvm/test/Analysis/ValueTracking/assume.ll
  llvm/test/Bitcode/attributes.ll
  llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
  llvm/test/Transforms/Attributor/align.ll
  llvm/test/Transforms/Attributor/nocapture-1.ll
  llvm/test/Transforms/Attributor/nonnull.ll
  llvm/test/Transforms/Attributor/norecurse.ll
  llvm/test/Transforms/Attributor/undefined_behavior.ll
  llvm/test/Transforms/CorrelatedValuePropagation/non-null.ll
  llvm/test/Transforms/FunctionAttrs/nocapture.ll
  llvm/test/Transforms/FunctionAttrs/nonnull.ll
  llvm/test/Transforms/GVN/PRE/2018-06-08-pre-load-dbgloc-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/MallocSROA-section-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-1-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-1.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-2-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-2.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-3-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-3.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-4-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-4.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-phi-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-phi.ll
  llvm/test/Transforms/GlobalOpt/load-store-global-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/malloc-promote-1-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/malloc-promote-1.ll
  llvm/test/Transforms/GlobalOpt/malloc-promote-2-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/malloc-promote-2.ll
  llvm/test/Transforms/GlobalOpt/storepointer-compare-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/storepointer-no-null-opt.ll
  llvm/test/Transforms/IPConstantProp/PR26044.ll
  llvm/test/Transforms/Inline/attributes.ll
  llvm/test/Transforms/InstCombine/atomic.ll
  llvm/test/Transforms/InstCombine/invariant.group.ll
  llvm/test/Transforms/InstCombine/invoke.ll
  llvm/test/Transforms/InstCombine/lifetime-no-null-opt.ll
  llvm/test/Transforms/InstCombine/load.ll
  llvm/test/Transforms/InstCombine/mem-deref-bytes.ll
  llvm/test/Transforms/InstCombine/memchr.ll
  llvm/test/Transforms/InstCombine/memcpy-addrspace.ll
  llvm/test/Transforms/InstCombine/memcpy-from-global.ll
  llvm/test/Transforms/InstCombine/memrchr.ll
  llvm/test/Transforms/InstCombine/select.ll
  llvm/test/Transforms/InstCombine/store.ll
  llvm/test/Transforms/InstCombine/strchr-1.ll
  llvm/test/Transforms/InstCombine/strcpy_chk-64.ll
  llvm/test/Transforms/InstCombine/strlen-1.ll
  llvm/test/Transforms/InstCombine/strncat-2.ll
  llvm/test/Transforms/InstCombine/strncmp-1.ll
  llvm/test/Transforms/InstCombine/strrchr-1.ll
  llvm/test/Transforms/InstCombine/strstr-1.ll
  llvm/test/Transforms/InstCombine/wcslen-1.ll
  llvm/test/Transforms/InstSimplify/compare.ll
  llvm/test/Transforms/LoopIdiom/pr28196.ll
  llvm/test/Transforms/LoopVersioning/lcssa.ll
  llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
  llvm/test/Transforms/SimplifyCFG/invoke.ll
  llvm/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll
  llvm/test/Transforms/SimplifyCFG/trap-no-null-opt-debugloc.ll
  llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
  llvm/test/Transforms/Util/assume-builder.ll
  mlir/test/Target/llvmir.mlir

Index: mlir/test/Target/llvmir.mlir
===
--- mlir/test/Target/llvmir.mlir
+++ mlir/test/Target/llvmir.mlir
@@ -1205,12 +1205,12 @@
 
 // CHECK-LABEL: @passthrough
 // CHECK: #[[ATTR_GROUP:[0-9]*]]
-llvm.func @passthrough() attributes {passthrough = ["noinline", ["alignstack", "4"], "null-pointer-is-valid", ["foo", "bar"]]} {
+llvm.func @passthrough() attributes {passthrough = ["noinline", ["alignstack", "4"], "null_pointer_is_valid", ["foo", "bar"]]} {
   llvm.return
 }
 
 // CHECK: attributes #[[ATTR_GROUP]] = {
 // CHECK-DAG: noinline
 // CHECK-DAG: alignstack=4
-// CHECK-DAG: "null-pointer-is-valid"
+// CHECK-DAG: null_pointer_is_valid
 // CHECK-DAG: "foo"="bar"
Index: llvm/te

[clang] c702d4b - [WebAssembly] Update latest implemented SIMD instructions

2020-05-15 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2020-05-15T10:53:02-07:00
New Revision: c702d4bf4110b65ba7a00daf3af3353ea5b74787

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

LOG: [WebAssembly] Update latest implemented SIMD instructions

Summary:
Move instructions that have recently been implemented in V8 from the
`unimplemented-simd128` target feature to the `simd128` target
feature. The updated instructions match the update at
https://github.com/WebAssembly/simd/pull/223.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, 
cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/Headers/wasm_simd128.h
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-arith.ll
llvm/test/CodeGen/WebAssembly/simd-build-vector.ll
llvm/test/CodeGen/WebAssembly/simd-offset.ll

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 5955237a0f58..d03905fdb991 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -70,7 +70,7 @@ TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i64_f64, 
"LLid", "nc", "nontrappi
 TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i64_f64, "LLid", "nc", 
"nontrapping-fptoint")
 
 // SIMD builtins
-TARGET_BUILTIN(__builtin_wasm_swizzle_v8x16, "V16cV16cV16c", "nc", 
"unimplemented-simd128")
+TARGET_BUILTIN(__builtin_wasm_swizzle_v8x16, "V16cV16cV16c", "nc", "simd128")
 
 TARGET_BUILTIN(__builtin_wasm_extract_lane_s_i8x16, "iV16cIi", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_extract_lane_u_i8x16, "iV16cIi", "nc", "simd128")

diff  --git a/clang/lib/Headers/wasm_simd128.h 
b/clang/lib/Headers/wasm_simd128.h
index 51e2a07716b3..d79b83b21c0e 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -50,8 +50,6 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_v128_load(const void *__mem) {
   return ((const struct __wasm_v128_load_struct *)__mem)->__v;
 }
 
-#ifdef __wasm_unimplemented_simd128__
-
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_v8x16_load_splat(const void *__mem) {
   struct __wasm_v8x16_load_splat_struct {
@@ -149,8 +147,6 @@ wasm_u64x2_load_32x2(const void *__mem) {
   return (v128_t) __builtin_convertvector(__v, __u64x2);
 }
 
-#endif // __wasm_unimplemented_simd128__
-
 static __inline__ void __DEFAULT_FN_ATTRS wasm_v128_store(void *__mem,
   v128_t __a) {
   // UB-free unaligned access copied from xmmintrin.h
@@ -564,15 +560,11 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_v128_xor(v128_t __a,
   return __a ^ __b;
 }
 
-#ifdef __wasm_unimplemented_simd128__
-
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_andnot(v128_t __a,
  v128_t __b) {
   return __a & ~__b;
 }
 
-#endif // __wasm_unimplemented_simd128__
-
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_bitselect(v128_t __a,
 v128_t __b,
 v128_t __mask) 
{
@@ -1066,15 +1058,11 @@ wasm_f32x4_convert_u32x4(v128_t __a) {
   __c1 * 8, __c1 * 8 + 1, __c1 * 8 + 2, __c1 * 8 + 3, __c1 * 8 + 4,
\
   __c1 * 8 + 5, __c1 * 8 + 6, __c1 * 8 + 7))
 
-#ifdef __wasm_unimplemented_simd128__
-
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v8x16_swizzle(v128_t __a,
v128_t __b) {
   return (v128_t)__builtin_wasm_swizzle_v8x16((__i8x16)__a, (__i8x16)__b);
 }
 
-#endif // __wasm_unimplemented_simd128__
-
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_i8x16_narrow_i16x8(v128_t __a, v128_t __b) {
   return (v128_t)__builtin_wasm_narrow_s_i8x16_i16x8((__i16x8)__a,

diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp 
b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
index 4a4585814381..0f8bb91ac496 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -239,12 +239,10 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
   }
 }
 // But some vector extending loads are legal
-if (Subtarget->hasUnimplementedSIMD128()) {
-  for (auto Ext : {ISD::EXTLOAD, ISD::SEXTLOAD, ISD::ZEXTLOAD}) {
-setLoadExtAction(Ext, MVT::v8i16, MVT::v8i8, Legal);
-setLoadExtAction(Ext, MVT::v4i32, MVT::v4i16, Legal);
-  

[PATCH] D79973: [WebAssembly] Update latest implemented SIMD instructions

2020-05-15 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc702d4bf4110: [WebAssembly] Update latest implemented SIMD 
instructions (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79973

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/Headers/wasm_simd128.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-arith.ll
  llvm/test/CodeGen/WebAssembly/simd-build-vector.ll
  llvm/test/CodeGen/WebAssembly/simd-offset.ll

Index: llvm/test/CodeGen/WebAssembly/simd-offset.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-offset.ll
+++ llvm/test/CodeGen/WebAssembly/simd-offset.ll
@@ -1,5 +1,4 @@
-; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-disable-explicit-locals -mattr=+unimplemented-simd128 | FileCheck %s --check-prefixes CHECK,SIMD128
-; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-disable-explicit-locals -mattr=+simd128 | FileCheck %s --check-prefixes CHECK,SIMD128-VM
+; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-disable-explicit-locals -mattr=+simd128 | FileCheck %s --check-prefixes CHECK,SIMD128
 ; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-disable-explicit-locals | FileCheck %s --check-prefixes CHECK,NO-SIMD128
 
 ; Test SIMD loads and stores
@@ -21,7 +20,6 @@
 }
 
 ; CHECK-LABEL: load_splat_v16i8:
-; SIMD128-VM-NOT: v8x16.load_splat
 ; NO-SIMD128-NOT: v128
 ; SIMD128-NEXT: .functype load_splat_v16i8 (i32) -> (v128){{$}}
 ; SIMD128-NEXT: v8x16.load_splat $push[[R:[0-9]+]]=, 0($0){{$}}
@@ -1594,7 +1592,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64 (i32) -> (v128){{$}}
 ; SIMD128-NEXT: i64x2.load32x2_u $push[[R:[0-9]+]]=, 0($0){{$}}
 ; SIMD128-NEXT: return $pop[[R]]{{$}}
@@ -1661,7 +1658,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64_with_folded_offset:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64_with_folded_offset (i32) -> (v128){{$}}
 ; SIMD128-NEXT: i64x2.load32x2_u $push[[R:[0-9]+]]=, 16($0){{$}}
 ; SIMD128-NEXT: return $pop[[R]]{{$}}
@@ -1723,7 +1719,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64_with_folded_gep_offset:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64_with_folded_gep_offset (i32) -> (v128){{$}}
 ; SIMD128-NEXT: i64x2.load32x2_u $push[[R:[0-9]+]]=, 8($0){{$}}
 ; SIMD128-NEXT: return $pop[[R]]{{$}}
@@ -1791,7 +1786,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64_with_unfolded_gep_negative_offset:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64_with_unfolded_gep_negative_offset (i32) -> (v128){{$}}
 ; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, -8{{$}}
 ; SIMD128-NEXT: i32.add $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
@@ -1869,7 +1863,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64_with_unfolded_offset:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64_with_unfolded_offset (i32) -> (v128){{$}}
 ; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 16{{$}}
 ; SIMD128-NEXT: i32.add $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
@@ -1941,7 +1934,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64_with_unfolded_gep_offset:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64_with_unfolded_gep_offset (i32) -> (v128){{$}}
 ; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 8{{$}}
 ; SIMD128-NEXT: i32.add $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
@@ -2007,7 +1999,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64_from_numeric_address:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64_from_numeric_address () -> (v128){{$}}
 ; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
 ; SIMD128-NEXT: i64x2.load32x2_u $push[[R:[0-9]+]]=, 32($pop[[L0]]){{$}}
@@ -2071,7 +2062,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64_from_global_address:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64_from_global_address () -> (v128){{$}}
 ; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
 ; SIMD128-NEXT: i64x2.load32x2_u $push[[R:[0-9]+]]=, gv_v2i32($pop[[L0]]){{$}}
Index: llvm/test/CodeGen/WebAssembly/simd-build-vector.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-build-vector.ll
+++ llvm/test/CodeGen/WebAssembly/simd-build-vector.ll
@@ -1,4 +1,5 @@
-; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-ret

[PATCH] D79400: [CMAKE] Fix build failure when source directory is read only

2020-05-15 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

I'd be interested in the answer concerning why we need to avoid `git rev-parse 
HEAD`; it seems like the cleanest solution is to just always check if `git 
rev-parse HEAD` changes to determine whether to regenerate the header.

If that is not feasible for some reason, I would lean towards your option (2), 
but I think more is needed in this patch to ensure the generation script is 
always run, right? How does //removing// a dependency cause the target to be 
executed each build? Don't we need to detect the case where `.git/logs/HEAD` is 
missing and make the target depend on `ALL` or whatever the CMake notion of 
"always out of date" is? We will also need to be OK with the regression in what 
happens when you do a `repo` checkout in a read-write context, as that will 
always run the script whereas before it would have the same behavior as a 
normal checkout. I don't know what the implication of all of these changes are, 
though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79400



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


[PATCH] D80023: [clang-tidy] Add abseil-string-find-str-contains checker.

2020-05-15 Thread Tom Lokovic via Phabricator via cfe-commits
tdl-g created this revision.
tdl-g added a reviewer: ymandel.
Herald added subscribers: cfe-commits, phosek, Charusso, mgorny.
Herald added a project: clang.
Eugene.Zelenko edited reviewers, added: alexfh, hokein, aaron.ballman, 
njames93; removed: ymandel.
Eugene.Zelenko added a project: clang-tools-extra.
Eugene.Zelenko retitled this revision from "Add abseil-string-find-str-contains 
checker." to "[clang-tidy] Add abseil-string-find-str-contains checker.".
Herald added a subscriber: xazax.hun.

This adds a checker which suggests replacing string.find(...) == npos with 
absl::StrContains.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80023

Files:
  clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
  clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
  clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/abseil-string-find-str-contains.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
@@ -0,0 +1,283 @@
+// RUN: %check_clang_tidy %s abseil-string-find-str-contains %t -- \
+// RUN:   -config="{CheckOptions: []}"
+
+using size_t = decltype(sizeof(int));
+
+namespace std {
+
+// Lightweight standin for std::string.
+template 
+class basic_string {
+public:
+  basic_string();
+  basic_string(const basic_string &);
+  basic_string(const C *);
+  ~basic_string();
+  int find(basic_string s, int pos = 0);
+  int find(const C *s, int pos = 0);
+  int find(char c, int pos = 0);
+  static constexpr size_t npos = -1;
+};
+typedef basic_string string;
+
+// Lightweight standin for std::string_view.
+template 
+class basic_string_view {
+public:
+  basic_string_view();
+  basic_string_view(const basic_string_view &);
+  basic_string_view(const C *);
+  ~basic_string_view();
+  int find(basic_string_view s, int pos = 0);
+  int find(const C *s, int pos = 0);
+  int find(char c, int pos = 0);
+  static constexpr size_t npos = -1;
+};
+typedef basic_string_view string_view;
+
+} // namespace std
+
+namespace absl {
+
+// Lightweight standin for absl::string_view.
+class string_view {
+public:
+  string_view();
+  string_view(const string_view &);
+  string_view(const char *);
+  ~string_view();
+  int find(string_view s, int pos = 0);
+  int find(const char *s, int pos = 0);
+  int find(char c, int pos = 0);
+  static constexpr size_t npos = -1;
+};
+
+} // namespace absl
+
+// Functions that take and return our various string-like types.
+std::string foo_ss(std::string);
+std::string_view foo_ssv(std::string_view);
+absl::string_view foo_asv(absl::string_view);
+std::string bar_ss();
+std::string_view bar_ssv();
+absl::string_view bar_asv();
+
+// Confirms that find==npos and find!=npos work for each supported type, when
+// npos comes from the correct type.
+void basic_tests() {
+  std::string ss;
+  ss.find("a") == std::string::npos;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StrContains instead of find() == npos
+  // CHECK-FIXES: {{^[[:space:]]*}}!absl::StrContains(ss, "a");{{$}}
+
+  ss.find("a") != std::string::npos;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StrContains instead of find() != npos
+  // CHECK-FIXES: {{^[[:space:]]*}}absl::StrContains(ss, "a");{{$}}
+
+  std::string::npos != ss.find("a");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StrContains instead of
+  // CHECK-FIXES: {{^[[:space:]]*}}absl::StrContains(ss, "a");{{$}}
+
+  std::string_view ssv;
+  ssv.find("a") == std::string_view::npos;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StrContains instead of
+  // CHECK-FIXES: {{^[[:space:]]*}}!absl::StrContains(ssv, "a");{{$}}
+
+  ssv.find("a") != std::string_view::npos;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StrContains instead of
+  // CHECK-FIXES: {{^[[:space:]]*}}absl::StrContains(ssv, "a");{{$}}
+
+  std::string_view::npos != ssv.find("a");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StrContains instead of
+  // CHECK-FIXES: {{^[[:space:]]*}}absl::StrContains(ssv, "a");{{$}}
+
+  absl::string_view asv;
+  asv.find("a") == absl::string_view::npos;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StrContains instead of
+  // CHECK-FIXES: {{^[[:space:]]*}}!absl::StrContains(asv, "a");{{$}}
+
+  asv.find("a") != absl::string_view::npos;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use absl::StrContains instead of
+  // CHECK-FIXES: {{^[[:space:]]*}}absl::StrContains(asv, "a");{{$}}
+
+  absl::string_view::npos != asv.find("a");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 

[PATCH] D79995: [clang] [MinGW] Fix libunwind extension

2020-05-15 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 updated this revision to Diff 264292.
mati865 added a comment.

Applied review comment and formatted.


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

https://reviews.llvm.org/D79995

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1234,7 +1234,14 @@
   case ToolChain::UNW_CompilerRT:
 if (LGT == LibGccType::StaticLibGcc)
   CmdArgs.push_back("-l:libunwind.a");
-else
+else if (TC.getTriple().isOSCygMing()) {
+  if (LGT == LibGccType::SharedLibGcc)
+CmdArgs.push_back("-l:libunwind.dll.a");
+  else
+// Let the linker choose between libunwind.dll.a and libunwind.a
+// depending on what's available, and depending on the -static flag
+CmdArgs.push_back("-lunwind");
+} else
   CmdArgs.push_back("-l:libunwind.so");
 break;
   }


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1234,7 +1234,14 @@
   case ToolChain::UNW_CompilerRT:
 if (LGT == LibGccType::StaticLibGcc)
   CmdArgs.push_back("-l:libunwind.a");
-else
+else if (TC.getTriple().isOSCygMing()) {
+  if (LGT == LibGccType::SharedLibGcc)
+CmdArgs.push_back("-l:libunwind.dll.a");
+  else
+// Let the linker choose between libunwind.dll.a and libunwind.a
+// depending on what's available, and depending on the -static flag
+CmdArgs.push_back("-lunwind");
+} else
   CmdArgs.push_back("-l:libunwind.so");
 break;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80001: [RFC/WIP][clang] Fix printing of names of inherited constructors

2020-05-15 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

@rsmith - this changes printing the name of inherited constructors in general, 
not just for debug info - could you take a gander and make sure that's probably 
OK for other callers trying to print the name of an inheriting constructor?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80001



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


[PATCH] D79465: [clang-format] Fix line lengths w/ comments in align

2020-05-15 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD updated this revision to Diff 264294.
JakeMerdichAMD added a comment.

Rebase to fix merge conflict


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79465

Files:
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11953,6 +11953,16 @@
"  x = 1;\n"
"y = 1;\n",
Alignment);
+
+  Alignment.ReflowComments = true;
+  Alignment.ColumnLimit = 50;
+  EXPECT_EQ("int x   = 0;\n"
+"int yy  = 1; /// specificlennospace\n"
+"int zzz = 2;\n",
+format("int x   = 0;\n"
+   "int yy  = 1; ///specificlennospace\n"
+   "int zzz = 2;\n",
+   Alignment));
 }
 
 TEST_F(FormatTest, AlignConsecutiveDeclarations) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -445,8 +445,16 @@
 
 unsigned ChangeMinColumn = Changes[i].StartOfTokenColumn;
 int LineLengthAfter = Changes[i].TokenLength;
-for (unsigned j = i + 1; j != e && Changes[j].NewlinesBefore == 0; ++j)
-  LineLengthAfter += Changes[j].Spaces + Changes[j].TokenLength;
+for (unsigned j = i + 1; j != e && Changes[j].NewlinesBefore == 0; ++j) {
+  LineLengthAfter += Changes[j].Spaces;
+  // Changes are generally 1:1 with the tokens, but a change could also be
+  // inside of a token, in which case it's counted more than once: once for
+  // the whitespace surrounding the token (!IsInsideToken) and once for
+  // each whitespace change within it (IsInsideToken).
+  // Therefore, changes inside of a token should only count the space.
+  if (!Changes[j].IsInsideToken)
+LineLengthAfter += Changes[j].TokenLength;
+}
 unsigned ChangeMaxColumn = Style.ColumnLimit - LineLengthAfter;
 
 // If we are restricted by the maximum column width, end the sequence.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11953,6 +11953,16 @@
"  x = 1;\n"
"y = 1;\n",
Alignment);
+
+  Alignment.ReflowComments = true;
+  Alignment.ColumnLimit = 50;
+  EXPECT_EQ("int x   = 0;\n"
+"int yy  = 1; /// specificlennospace\n"
+"int zzz = 2;\n",
+format("int x   = 0;\n"
+   "int yy  = 1; ///specificlennospace\n"
+   "int zzz = 2;\n",
+   Alignment));
 }
 
 TEST_F(FormatTest, AlignConsecutiveDeclarations) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -445,8 +445,16 @@
 
 unsigned ChangeMinColumn = Changes[i].StartOfTokenColumn;
 int LineLengthAfter = Changes[i].TokenLength;
-for (unsigned j = i + 1; j != e && Changes[j].NewlinesBefore == 0; ++j)
-  LineLengthAfter += Changes[j].Spaces + Changes[j].TokenLength;
+for (unsigned j = i + 1; j != e && Changes[j].NewlinesBefore == 0; ++j) {
+  LineLengthAfter += Changes[j].Spaces;
+  // Changes are generally 1:1 with the tokens, but a change could also be
+  // inside of a token, in which case it's counted more than once: once for
+  // the whitespace surrounding the token (!IsInsideToken) and once for
+  // each whitespace change within it (IsInsideToken).
+  // Therefore, changes inside of a token should only count the space.
+  if (!Changes[j].IsInsideToken)
+LineLengthAfter += Changes[j].TokenLength;
+}
 unsigned ChangeMaxColumn = Style.ColumnLimit - LineLengthAfter;
 
 // If we are restricted by the maximum column width, end the sequence.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80025: [ASTMatcher] Correct memoization bug ignoring direction (descendants or ancestors)

2020-05-15 Thread Loïc Joly via Phabricator via cfe-commits
loic-joly-sonarsource created this revision.
loic-joly-sonarsource added a reviewer: klimek.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In ASTMatcher, when we have `has(...)` and `hasParent(...)` called with the 
same internal matcher on the same node, the memoization process will mix-up the 
two calls because the direction of the traversal is not part of the memoization 
key.

This patch adds this information.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80025

Files:
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -2591,6 +2591,14 @@
 compoundStmt(hasParent(ifStmt();
 }
 
+TEST(MatcherMemoize, HasParentDiffersFromHas) {
+  // Test introduced after detecting a bug in memoization
+EXPECT_TRUE(matches(
+  "void f() { throw 1; }",
+  expr(eachOf(cxxThrowExpr(hasParent(expr())),
+  cxxThrowExpr(has(expr()));
+}
+
 TEST(HasAncestor, MatchesAllAncestors) {
   EXPECT_TRUE(matches(
 "template  struct C { static void f() { 42; } };"
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -43,6 +43,11 @@
 // optimize this on.
 static const unsigned MaxMemoizationEntries = 1;
 
+enum class MatchDirection {
+  Ancestors,
+  Descendants
+};
+
 // We use memoization to avoid running the same matcher on the same
 // AST node twice.  This struct is the key for looking up match
 // result.  It consists of an ID of the MatcherInterface (for
@@ -60,11 +65,12 @@
   ast_type_traits::DynTypedNode Node;
   BoundNodesTreeBuilder BoundNodes;
   ast_type_traits::TraversalKind Traversal = ast_type_traits::TK_AsIs;
+  MatchDirection Direction;
 
   bool operator<(const MatchKey &Other) const {
-return std::tie(MatcherID, Node, BoundNodes, Traversal) <
+return std::tie(MatcherID, Node, BoundNodes, Traversal, Direction) <
std::tie(Other.MatcherID, Other.Node, Other.BoundNodes,
-Other.Traversal);
+Other.Traversal, Other.Direction);
   }
 };
 
@@ -457,6 +463,7 @@
 // Note that we key on the bindings *before* the match.
 Key.BoundNodes = *Builder;
 Key.Traversal = Ctx.getTraversalKind();
+Key.Direction = MatchDirection::Descendants;
 
 MemoizationMap::iterator I = ResultCache.find(Key);
 if (I != ResultCache.end()) {
@@ -706,6 +713,7 @@
 Key.Node = Node;
 Key.BoundNodes = *Builder;
 Key.Traversal = Ctx.getTraversalKind();
+Key.Direction = MatchDirection::Ancestors;
 
 // Note that we cannot use insert and reuse the iterator, as recursive
 // calls to match might invalidate the result cache iterators.


Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -2591,6 +2591,14 @@
 compoundStmt(hasParent(ifStmt();
 }
 
+TEST(MatcherMemoize, HasParentDiffersFromHas) {
+  // Test introduced after detecting a bug in memoization
+EXPECT_TRUE(matches(
+  "void f() { throw 1; }",
+  expr(eachOf(cxxThrowExpr(hasParent(expr())),
+  cxxThrowExpr(has(expr()));
+}
+
 TEST(HasAncestor, MatchesAllAncestors) {
   EXPECT_TRUE(matches(
 "template  struct C { static void f() { 42; } };"
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -43,6 +43,11 @@
 // optimize this on.
 static const unsigned MaxMemoizationEntries = 1;
 
+enum class MatchDirection {
+  Ancestors,
+  Descendants
+};
+
 // We use memoization to avoid running the same matcher on the same
 // AST node twice.  This struct is the key for looking up match
 // result.  It consists of an ID of the MatcherInterface (for
@@ -60,11 +65,12 @@
   ast_type_traits::DynTypedNode Node;
   BoundNodesTreeBuilder BoundNodes;
   ast_type_traits::TraversalKind Traversal = ast_type_traits::TK_AsIs;
+  MatchDirection Direction;
 
   bool operator<(const MatchKey &Other) const {
-return std::tie(MatcherID, Node, BoundNodes, Traversal) <
+return std::tie(MatcherID, Node, BoundNodes, Traversal, Direction) <
std::tie(Other.MatcherID, Other.Node, Other.BoundNodes,
-Other.Traversal);
+Other.Traversal, Other.Direction);
   }
 };
 
@@ -457,6 +463,7 @@
 // Note that we key on the bindings *before* t

[PATCH] D80023: [clang-tidy] Add abseil-string-find-str-contains checker.

2020-05-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp:18
+#include "clang/Tooling/Transformer/Stencil.h"
+#include 
+

asserts are not used.



Comment at: 
clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp:35
+llvm::Optional
+MakeRule(const LangOptions &LangOpts,
+ const ClangTidyCheck::OptionsView &Options) {

Please use static instead of anonymous namespace for functions.



Comment at: 
clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp:38
+  // Only support C++.
+  if (!LangOpts.CPlusPlus)
+return llvm::None;

This belongs to isLanguageVersionSupported().



Comment at: clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.h:16
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include 
+#include 

STL containers are not used in header.



Comment at: clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.h:32
+  StringFindStrContainsCheck(StringRef Name, ClangTidyContext *Context);
+};
+

storeOptions() is missing.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:78
 ^^
+- New :doc:`abseil-string-find-str-contains
+  ` check.

Please separate with empty line.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:81
+
+   Finds string.find(...) == npos comparisons and suggests replacing with
+   absl::StrContains.

Please synchronize with first statement in documentation.



Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:15
 
-   `abseil-duration-addition `_, "Yes"
-   `abseil-duration-comparison `_, "Yes"
-   `abseil-duration-conversion-cast `_, 
"Yes"
-   `abseil-duration-division `_, "Yes"
-   `abseil-duration-factory-float `_, "Yes"
-   `abseil-duration-factory-scale `_, "Yes"
-   `abseil-duration-subtraction `_, "Yes"
-   `abseil-duration-unnecessary-conversion 
`_, "Yes"
-   `abseil-faster-strsplit-delimiter 
`_, "Yes"
+   `abseil-duration-addition `_,
+   `abseil-duration-comparison `_,

Unrelated and incorrect changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80023



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


[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-05-15 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 264300.
zequanwu added a comment.

Since the new warning is controlled by `-Wuninitialized`, I disabled it in 
existing test case and added a separate test case for 
`-Wuninitialized-const-reference`.


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

https://reviews.llvm.org/D79895

Files:
  clang/include/clang/Analysis/Analyses/UninitializedValues.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Analysis/UninitializedValues.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/Misc/warning-wall.c
  clang/test/SemaCXX/uninit-variables.cpp
  clang/test/SemaCXX/uninitialized.cpp
  clang/test/SemaCXX/warn-uninitialized-const-reference.cpp

Index: clang/test/SemaCXX/warn-uninitialized-const-reference.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-uninitialized-const-reference.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized-const-reference -verify %s
+
+class A {
+public:
+int i;
+A() {};
+A(const A& a) {};
+A(int i) {}
+bool operator!=(const A&);
+};
+
+A const_ref_use_A(const A& a);
+int const_ref_use(const int& i);
+A const_use_A(const A a);
+int const_use(const int i);
+
+void f() {
+int i;
+const_ref_use(i); // expected-warning {{variable 'i' is uninitialized when passes as a const reference parameter here}}
+int j = j + const_ref_use(j); // expected-warning {{variable 'j' is uninitialized when used within its own initialization}} expected-warning {{variable 'j' is uninitialized when passes as a const reference parameter here}}
+A a1 = const_ref_use_A(a1); // expected-warning {{variable 'a1' is uninitialized when passes as a const reference parameter here}}
+int k = const_use(k); // expected-warning {{variable 'k' is uninitialized when used within its own initialization}}
+A a2 = const_use_A(a2); // expected-warning {{variable 'a2' is uninitialized when used within its own initialization}}
+A a3(const_ref_use_A(a3)); // expected-warning {{variable 'a3' is uninitialized when passes as a const reference parameter here}}
+A a4 = a3 != a4; // expected-warning {{variable 'a4' is uninitialized when used within its own initialization}} expected-warning {{variable 'a4' is uninitialized when passes as a const reference parameter here}}
+
+A a5;
+const_ref_use_A(a5);
+}
Index: clang/test/SemaCXX/uninitialized.cpp
===
--- clang/test/SemaCXX/uninitialized.cpp
+++ clang/test/SemaCXX/uninitialized.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -Wno-unused-value -Wno-unused-lambda-capture -std=c++1z -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -Wno-unused-value -Wno-unused-lambda-capture -Wno-uninitialized-const-reference -std=c++1z -verify %s
 
 // definitions for std::move
 namespace std {
Index: clang/test/SemaCXX/uninit-variables.cpp
===
--- clang/test/SemaCXX/uninit-variables.cpp
+++ clang/test/SemaCXX/uninit-variables.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -fsyntax-only -fcxx-exceptions %s -verify -std=c++1y
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -Wno-uninitialized-const-reference -fsyntax-only -fcxx-exceptions %s -verify -std=c++1y
 
 // Stub out types for 'typeid' to work.
 namespace std { class type_info {}; }
Index: clang/test/Misc/warning-wall.c
===
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -55,6 +55,7 @@
 CHECK-NEXT:-Wuninitialized
 CHECK-NEXT:  -Wsometimes-uninitialized
 CHECK-NEXT:  -Wstatic-self-init
+CHECK-NEXT:  -Wuninitialized-const-reference
 CHECK-NEXT:-Wunknown-pragmas
 CHECK-NEXT:-Wunused
 CHECK-NEXT:  -Wunused-argument
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -974,6 +974,14 @@
 << Use.getUser()->getSourceRange();
 }
 
+/// Diagnose uninitialized const reference usages.
+static bool DiagnoseUninitializedConstRefUse(Sema &S, const VarDecl *VD,
+ const UninitUse &Use) {
+  S.Diag(Use.getUser()->getBeginLoc(), diag::warn_uninit_const_reference)
+  << VD->getDeclName() << Use.getUser()->getSourceRange();
+  return true;
+}
+
 /// DiagnoseUninitializedUse -- Helper function for diagnosing uses of an
 /// uninitialized variable. This manages the different forms of diagnostic
 /// emitted for particular types of uses. Returns true if the use was diagnosed
@@ -1000,8 +1008,9 @@
 
   ContainsReference CR(S.Context, DRE);
   CR.Visit(Initializer);
+  unsigned DiagID = 

[PATCH] D79967: Fix debug info for NoDebug attr

2020-05-15 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a subscriber: vsk.
dblaikie added a comment.

Could you check the commit history for this feature and rope in some folks who 
added the function declaration work (it's for debug call sites) - maybe @vsk is 
the right person, or knows who is, to check this is the right fix for 
it/doesn't adversely affect the feature this code was added to implement.




Comment at: clang/test/CodeGen/nodebug-attr.c:5-6
+
+// CHECK-NOT: define {{.*}}@foo{{.*}}!dbg
+// CHECK-LABEL: define {{.*}}@foo
+// CHECK-NOT: ret {{.*}}!dbg

Does this test fail when the bug is present? I'd have thought not - my 
understanding was that CHECK-LABEL is found first, then CHECK-NOT is tested 
between labels/other checks, so it wouldn't find @foo.*!dbg anyway.

I think maybe it'd be better to tighten up the CHECK-LABEL to include "#0 {" at 
the end and a comment saying how that CHECK part ensures there's no !dbg 
attached to it.



Comment at: clang/test/CodeGen/nodebug-attr.c:8-15
+__attribute__((nodebug)) void foo(int *a) {
+  *a = 1;
+}
+
+// CHECK-LABEL: define {{.*}}@bar{{.*}}!dbg
+void bar(int *a) {
+  foo(a);

It looks like this test case currently crashes LLVM:

h$ clang++-tot test.cpp -g -c -O3 && llvm-dwarfdump-tot test.o
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: clang++-tot test.cpp -g -c -O3 
1.   parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module 'test.cpp'.
4.  Running pass 'Debug Variable Analysis' on function '@_Z3fooPi'
 #0 0x06b49927 llvm::sys::PrintStackTrace(llvm::raw_ostream&) 
/usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Support/Unix/Signals.inc:564:11
 #1 0x06b49ac9 PrintStackTraceSignalHandler(void*) 
/usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Support/Unix/Signals.inc:625:1
 #2 0x06b482db llvm::sys::RunSignalHandlers() 
/usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Support/Signals.cpp:67:5
 #3 0x06b4921e llvm::sys::CleanupOnSignal(unsigned long) 
/usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Support/Unix/Signals.inc:362:1
 #4 0x06a7cae8 (anonymous 
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) 
/usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Support/CrashRecoveryContext.cpp:77:20
 #5 0x06a7cd6e CrashRecoverySignalHandler(int) 
/usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/Support/CrashRecoveryContext.cpp:383:1
 #6 0x7fc197167520 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x13520)
 #7 0x05a309ac llvm::DICompileUnit::getEmissionKind() const 
/usr/local/google/home/blaikie/dev/llvm/src/llvm/include/llvm/IR/DebugInfoMetadata.h:1272:31
 #8 0x05a4a107 llvm::LexicalScopes::initialize(llvm::MachineFunction 
const&) 
/usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/CodeGen/LexicalScopes.cpp:53:70
 #9 0x05e128dd (anonymous namespace)::LDVImpl::computeIntervals() 
/usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/CodeGen/LiveDebugVariables.cpp:972:17
#10 0x05e11284 (anonymous 
namespace)::LDVImpl::runOnMachineFunction(llvm::MachineFunction&) 
/usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/CodeGen/LiveDebugVariables.cpp:0:3
#11 0x05e10fe4 
llvm::LiveDebugVariables::runOnMachineFunction(llvm::MachineFunction&) 
/usr/local/google/home/blaikie/dev/llvm/src/llvm/lib/CodeGen/LiveDebugVariables.cpp:1014:3


Is that crash something this patch is intended to address, or unrelated? I 
guess it's intended to address that problem - because it's a DISubprogram for 
'foo' with no DICompileUnit attachment that causes the crash later on.


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

https://reviews.llvm.org/D79967



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


[PATCH] D80020: [PowerPC] Add support for -mcpu=pwr10 in both clang and llvm

2020-05-15 Thread Lei Huang via Phabricator via cfe-commits
lei updated this revision to Diff 264301.
lei added a comment.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Add support in llvm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80020

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Driver/ToolChains/Arch/PPC.cpp
  clang/test/Misc/target-invalid-cpu-note.c
  clang/test/Preprocessor/init-ppc64.c
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h
  llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
  llvm/test/CodeGen/PowerPC/check-cpu.ll

Index: llvm/test/CodeGen/PowerPC/check-cpu.ll
===
--- llvm/test/CodeGen/PowerPC/check-cpu.ll
+++ llvm/test/CodeGen/PowerPC/check-cpu.ll
@@ -2,6 +2,10 @@
 ; RUN: -mcpu=future < %s | FileCheck %s
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
 ; RUN: -mcpu=future < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN: -mcpu=power10 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN: -mcpu=pwr10 < %s | FileCheck %s
 
 
 ; Test mcpu=future that should be recognized on PowerPC.
Index: llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
===
--- llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
+++ llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
@@ -654,7 +654,8 @@
   unsigned Directive = ST->getCPUDirective();
   // Assume that Future CPU has the same cache line size as the others.
   if (Directive == PPC::DIR_PWR7 || Directive == PPC::DIR_PWR8 ||
-  Directive == PPC::DIR_PWR9 || Directive == PPC::DIR_PWR_FUTURE)
+  Directive == PPC::DIR_PWR9 || Directive == PPC::DIR_PWR10 ||
+  Directive == PPC::DIR_PWR_FUTURE)
 return 128;
 
   // On other processors return a default of 64 bytes.
@@ -688,7 +689,8 @@
   // FIXME: the same for P9 as previous gen until POWER9 scheduling is ready
   // Assume that future is the same as the others.
   if (Directive == PPC::DIR_PWR7 || Directive == PPC::DIR_PWR8 ||
-  Directive == PPC::DIR_PWR9 || Directive == PPC::DIR_PWR_FUTURE)
+  Directive == PPC::DIR_PWR9 || Directive == PPC::DIR_PWR10 ||
+  Directive == PPC::DIR_PWR_FUTURE)
 return 12;
 
   // For most things, modern systems have two execution units (and
Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -57,6 +57,7 @@
 DIR_PWR7,
 DIR_PWR8,
 DIR_PWR9,
+DIR_PWR10,
 DIR_PWR_FUTURE,
 DIR_64
   };
@@ -138,6 +139,7 @@
   bool HasAddiLoadFusion;
   bool HasAddisLoadFusion;
   bool IsISA3_0;
+  bool IsISA3_1;
   bool UseLongCalls;
   bool SecurePlt;
   bool VectorsUseTwoUnits;
@@ -308,6 +310,7 @@
   bool hasHTM() const { return HasHTM; }
   bool hasFloat128() const { return HasFloat128; }
   bool isISA3_0() const { return IsISA3_0; }
+  bool isISA3_1() const { return IsISA3_1; }
   bool useLongCalls() const { return UseLongCalls; }
   bool hasFusion() const { return HasFusion; }
   bool hasAddiLoadFusion() const { return HasAddiLoadFusion; }
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -1305,6 +1305,7 @@
   case PPC::DIR_PWR7:
   case PPC::DIR_PWR8:
   case PPC::DIR_PWR9:
+  case PPC::DIR_PWR10:
   case PPC::DIR_PWR_FUTURE:
 setPrefLoopAlignment(Align(16));
 setPrefFunctionAlignment(Align(16));
@@ -14896,6 +14897,7 @@
   case PPC::DIR_PWR7:
   case PPC::DIR_PWR8:
   case PPC::DIR_PWR9:
+  case PPC::DIR_PWR10:
   case PPC::DIR_PWR_FUTURE: {
 if (!ML)
   break;
@@ -16085,6 +16087,7 @@
   // vector7   2  2
   return true;
 case PPC::DIR_PWR9:
+case PPC::DIR_PWR10:
 case PPC::DIR_PWR_FUTURE:
   //  typemul addshl
   // scalar5   2  2
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -51,6 +51,7 @@
 def DirectivePwr7: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR7", "">;
 def DirectivePwr8: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR8", "">;
 def DirectivePwr9: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR9", "">;
+def DirectivePwr10: SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR10", "">;
 def DirectivePwrFuture
 : SubtargetFeature<"", "CPUDirective", "PPC::DIR_PWR_FUTURE", "">;
 
@@ -205,6 +206,9 @@
 def FeatureISA3_0 : Subt

[PATCH] D80020: [PowerPC] Add support for -mcpu=pwr10 in both clang and llvm

2020-05-15 Thread Lei Huang via Phabricator via cfe-commits
lei updated this revision to Diff 264303.
lei retitled this revision from " [PowerPC] Add support for -mcpu=pwr10 in both 
clang and llvm" to "[PowerPC] Add support for -mcpu=pwr10 in both clang and 
llvm".
lei added a comment.

missed a file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80020

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Driver/ToolChains/Arch/PPC.cpp
  clang/test/Misc/target-invalid-cpu-note.c
  clang/test/Preprocessor/init-ppc64.c
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h
  llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
  llvm/test/CodeGen/PowerPC/check-cpu.ll

Index: llvm/test/CodeGen/PowerPC/check-cpu.ll
===
--- llvm/test/CodeGen/PowerPC/check-cpu.ll
+++ llvm/test/CodeGen/PowerPC/check-cpu.ll
@@ -2,6 +2,10 @@
 ; RUN: -mcpu=future < %s | FileCheck %s
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
 ; RUN: -mcpu=future < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN: -mcpu=power10 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN: -mcpu=pwr10 < %s | FileCheck %s
 
 
 ; Test mcpu=future that should be recognized on PowerPC.
Index: llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
===
--- llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
+++ llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
@@ -654,7 +654,8 @@
   unsigned Directive = ST->getCPUDirective();
   // Assume that Future CPU has the same cache line size as the others.
   if (Directive == PPC::DIR_PWR7 || Directive == PPC::DIR_PWR8 ||
-  Directive == PPC::DIR_PWR9 || Directive == PPC::DIR_PWR_FUTURE)
+  Directive == PPC::DIR_PWR9 || Directive == PPC::DIR_PWR10 ||
+  Directive == PPC::DIR_PWR_FUTURE)
 return 128;
 
   // On other processors return a default of 64 bytes.
@@ -688,7 +689,8 @@
   // FIXME: the same for P9 as previous gen until POWER9 scheduling is ready
   // Assume that future is the same as the others.
   if (Directive == PPC::DIR_PWR7 || Directive == PPC::DIR_PWR8 ||
-  Directive == PPC::DIR_PWR9 || Directive == PPC::DIR_PWR_FUTURE)
+  Directive == PPC::DIR_PWR9 || Directive == PPC::DIR_PWR10 ||
+  Directive == PPC::DIR_PWR_FUTURE)
 return 12;
 
   // For most things, modern systems have two execution units (and
Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -34,32 +34,33 @@
 
 namespace PPC {
   // -m directive values.
-  enum {
-DIR_NONE,
-DIR_32,
-DIR_440,
-DIR_601,
-DIR_602,
-DIR_603,
-DIR_7400,
-DIR_750,
-DIR_970,
-DIR_A2,
-DIR_E500,
-DIR_E500mc,
-DIR_E5500,
-DIR_PWR3,
-DIR_PWR4,
-DIR_PWR5,
-DIR_PWR5X,
-DIR_PWR6,
-DIR_PWR6X,
-DIR_PWR7,
-DIR_PWR8,
-DIR_PWR9,
-DIR_PWR_FUTURE,
-DIR_64
-  };
+enum {
+  DIR_NONE,
+  DIR_32,
+  DIR_440,
+  DIR_601,
+  DIR_602,
+  DIR_603,
+  DIR_7400,
+  DIR_750,
+  DIR_970,
+  DIR_A2,
+  DIR_E500,
+  DIR_E500mc,
+  DIR_E5500,
+  DIR_PWR3,
+  DIR_PWR4,
+  DIR_PWR5,
+  DIR_PWR5X,
+  DIR_PWR6,
+  DIR_PWR6X,
+  DIR_PWR7,
+  DIR_PWR8,
+  DIR_PWR9,
+  DIR_PWR10,
+  DIR_PWR_FUTURE,
+  DIR_64
+};
 }
 
 class GlobalValue;
@@ -138,6 +139,7 @@
   bool HasAddiLoadFusion;
   bool HasAddisLoadFusion;
   bool IsISA3_0;
+  bool IsISA3_1;
   bool UseLongCalls;
   bool SecurePlt;
   bool VectorsUseTwoUnits;
@@ -308,6 +310,7 @@
   bool hasHTM() const { return HasHTM; }
   bool hasFloat128() const { return HasFloat128; }
   bool isISA3_0() const { return IsISA3_0; }
+  bool isISA3_1() const { return IsISA3_1; }
   bool useLongCalls() const { return UseLongCalls; }
   bool hasFusion() const { return HasFusion; }
   bool hasAddiLoadFusion() const { return HasAddiLoadFusion; }
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -1305,6 +1305,7 @@
   case PPC::DIR_PWR7:
   case PPC::DIR_PWR8:
   case PPC::DIR_PWR9:
+  case PPC::DIR_PWR10:
   case PPC::DIR_PWR_FUTURE:
 setPrefLoopAlignment(Align(16));
 setPrefFunctionAlignment(Align(16));
@@ -14896,6 +14897,7 @@
   case PPC::DIR_PWR7:
   case PPC::DIR_PWR8:
   case PPC::DIR_PWR9:
+  case PPC::DIR_PWR10:
   case PPC::DIR_PWR_FUTURE: {
 if (!ML)
   break;
@@ -16085,6 +16087,7 @@
   // vector7   2  2
   return true;
 case PPC::DIR_PWR9:
+case PPC::DIR_PWR10:
 case

[clang] 18a855d - [clang][slh] Add test for SLH feature checking macro

2020-05-15 Thread Zola Bridges via cfe-commits

Author: Zola Bridges
Date: 2020-05-15T12:23:31-07:00
New Revision: 18a855da431e74499695ce43a8db23a1755ba632

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

LOG: [clang][slh] Add test for SLH feature checking macro

Summary:
I forgot to include a test in this commit:
https://reviews.llvm.org/rG379e68a763097bed6c6dc7453e4b732e3d68

Here's the test. It passes after that commit and fails before that commit.

Reviewed By: mattdr

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

Added: 
clang/test/Lexer/has_feature_speculative_load_hardening.cpp

Modified: 


Removed: 




diff  --git a/clang/test/Lexer/has_feature_speculative_load_hardening.cpp 
b/clang/test/Lexer/has_feature_speculative_load_hardening.cpp
new file mode 100644
index ..3bc743f286c7
--- /dev/null
+++ b/clang/test/Lexer/has_feature_speculative_load_hardening.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang -E -mspeculative-load-hardening %s -o - | FileCheck 
--check-prefix=CHECK-SLH %s
+// RUN: %clang -E -mno-speculative-load-hardening %s -o - | FileCheck 
--check-prefix=CHECK-NOSLH %s
+// RUN: %clang -E %s -o - | FileCheck --check-prefix=CHECK-DEFAULT %s
+
+#if __has_feature(speculative_load_hardening)
+int SpeculativeLoadHardeningEnabled();
+#else
+int SpeculativeLoadHardeningDisabled();
+#endif
+
+// CHECK-SLH: SpeculativeLoadHardeningEnabled
+
+// CHECK-NOSLH: SpeculativeLoadHardeningDisabled
+
+// CHECK-DEFAULT: SpeculativeLoadHardeningDisabled



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


  1   2   >