[PATCH] D86858: [OpenMP] Fix infinite loop in Sema::isOpenMPGlobalCapturedDecl()

2020-08-31 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp added a comment.

@jdoerfert @ABataev
I don't have commit access, can you help commit this?
Yang Fan 
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86858

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


[clang] 113861b - Fix -Wcompound-token-split to give the same warnings under -E

2020-08-31 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-08-31T20:59:20-07:00
New Revision: 113861b444610aebd1c05760a3e0ee6284f42211

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

LOG: Fix -Wcompound-token-split to give the same warnings under -E
-frewrite-includes.

Remove the special-case (and highly implausible) diagnostic for a
compound token that crosses a file boundary, and instead model that case
the same as a compound token separated by whitespace, so that file
transitions and presumed file transitions behave the same way.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/Parse/Parser.cpp
clang/test/Parser/compound-token-split.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 42da8bbad74f..0e51fef8659e 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -70,9 +70,6 @@ def subst_compound_token_kind : TextSubstitution<
 def warn_compound_token_split_by_macro : Warning<
   "%sub{subst_compound_token_kind}0,1,2,3 appear in 
diff erent "
   "macro expansion contexts">, InGroup;
-def warn_compound_token_split_by_file : Warning<
-  "%sub{subst_compound_token_kind}0,1,2,3 appear in 
diff erent source files">,
-  InGroup;
 def note_compound_token_split_second_token_here : Note<
   "%select{|second }0%1 token is here">;
 def warn_compound_token_split_by_whitespace : Warning<

diff  --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 70e6e74ade89..c72ffde8fc26 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -233,13 +233,12 @@ void Parser::checkCompoundToken(SourceLocation 
FirstTokLoc,
 return;
   SourceLocation SecondTokLoc = Tok.getLocation();
 
-  // We expect both tokens to come from the same FileID.
-  FileID FirstID = PP.getSourceManager().getFileID(FirstTokLoc);
-  FileID SecondID = PP.getSourceManager().getFileID(SecondTokLoc);
-  if (FirstID != SecondID) {
-Diag(FirstTokLoc, (FirstTokLoc.isMacroID() || SecondTokLoc.isMacroID())
-  ? diag::warn_compound_token_split_by_macro
-  : diag::warn_compound_token_split_by_file)
+  // If either token is in a macro, we expect both tokens to come from the same
+  // macro expansion.
+  if ((FirstTokLoc.isMacroID() || SecondTokLoc.isMacroID()) &&
+  PP.getSourceManager().getFileID(FirstTokLoc) !=
+  PP.getSourceManager().getFileID(SecondTokLoc)) {
+Diag(FirstTokLoc, diag::warn_compound_token_split_by_macro)
 << (FirstTokKind == Tok.getKind()) << FirstTokKind << Tok.getKind()
 << static_cast(Op) << SourceRange(FirstTokLoc);
 Diag(SecondTokLoc, diag::note_compound_token_split_second_token_here)
@@ -249,7 +248,7 @@ void Parser::checkCompoundToken(SourceLocation FirstTokLoc,
   }
 
   // We expect the tokens to abut.
-  if (Tok.hasLeadingSpace()) {
+  if (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()) {
 SourceLocation SpaceLoc = PP.getLocForEndOfToken(FirstTokLoc);
 if (SpaceLoc.isInvalid())
   SpaceLoc = FirstTokLoc;

diff  --git a/clang/test/Parser/compound-token-split.cpp 
b/clang/test/Parser/compound-token-split.cpp
index 0f1774a10714..6b77bf386087 100644
--- a/clang/test/Parser/compound-token-split.cpp
+++ b/clang/test/Parser/compound-token-split.cpp
@@ -1,8 +1,12 @@
 // RUN: %clang_cc1 %s -verify
 // RUN: %clang_cc1 %s -verify=expected,space -Wcompound-token-split
 
+// Ensure we get the same warnings after -frewrite-includes
+// RUN: %clang_cc1 %s -E -frewrite-includes -o %t
+// RUN: %clang_cc1 -x c++ %t -verify=expected,space -Wcompound-token-split
+
 #ifdef LSQUARE
-[ // expected-note {{second '[' token is here}}
+[
 #else
 
 #define VAR(type, name, init) type name = (init)
@@ -26,7 +30,7 @@ int f2() {
   return n;
 }
 
-[ // expected-warning-re ^}}'[' tokens introducing attribute appear in 
diff erent source files}}
+[ // space-warning-re ^}}'[' tokens introducing attribute are separated by 
whitespace}}
 #define LSQUARE
 #include __FILE__
   noreturn ]]  void g();



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


[clang] 0da8453 - Remove -Wcompound-token-split-by-space from -Wall.

2020-08-31 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-08-31T20:59:19-07:00
New Revision: 0da84535b1e328188efbc1bb697dc7276f9e7d27

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

LOG: Remove -Wcompound-token-split-by-space from -Wall.

Use of a linebreak between the `(` and `{` in a GNU statement-expression
appears to be too common to include this warning in -Wall -- this occurs
in some Linux kernel headers, for example.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/test/Misc/warning-wall.c
clang/test/Parser/compound-token-split.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index a79e057a5b33..6b4dcc850612 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -949,7 +949,7 @@ def Consumed   : DiagGroup<"consumed">;
 // warning should be active _only_ when -Wall is passed in, mark it as
 // DefaultIgnore in addition to putting it here.
 def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool,
-MisleadingIndentation, CompoundTokenSplit]>;
+MisleadingIndentation]>;
 
 // Warnings that should be in clang-cl /w4.
 def : DiagGroup<"CL4", [All, Extra]>;

diff  --git a/clang/test/Misc/warning-wall.c b/clang/test/Misc/warning-wall.c
index 6e1134572a3c..c63d4beecff0 100644
--- a/clang/test/Misc/warning-wall.c
+++ b/clang/test/Misc/warning-wall.c
@@ -94,9 +94,6 @@ CHECK-NEXT:-Wdangling-else
 CHECK-NEXT:  -Wswitch
 CHECK-NEXT:  -Wswitch-bool
 CHECK-NEXT:  -Wmisleading-indentation
-CHECK-NEXT:  -Wcompound-token-split
-CHECK-NEXT:-Wcompound-token-split-by-macro
-CHECK-NEXT:-Wcompound-token-split-by-space
 
 
 CHECK-NOT:-W

diff  --git a/clang/test/Parser/compound-token-split.cpp 
b/clang/test/Parser/compound-token-split.cpp
index 2ec7955658de..0f1774a10714 100644
--- a/clang/test/Parser/compound-token-split.cpp
+++ b/clang/test/Parser/compound-token-split.cpp
@@ -1,6 +1,5 @@
 // RUN: %clang_cc1 %s -verify
 // RUN: %clang_cc1 %s -verify=expected,space -Wcompound-token-split
-// RUN: %clang_cc1 %s -verify=expected,space -Wall
 
 #ifdef LSQUARE
 [ // expected-note {{second '[' token is here}}



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


[PATCH] D86858: [OpenMP] Fix infinite loop in Sema::isOpenMPGlobalCapturedDecl()

2020-08-31 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp updated this revision to Diff 289069.
nullptr.cpp added a comment.

trigger rebuild


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86858

Files:
  clang/lib/Sema/SemaOpenMP.cpp


Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -2430,7 +2430,7 @@
 DSAStackTy::DSAVarData DVar = DSAStack->getImplicitDSA(D, Level);
 if (DVar.CKind != OMPC_shared)
   return true;
-  } while (Level >= 0);
+  } while (Level > 0);
 }
   }
   return true;


Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -2430,7 +2430,7 @@
 DSAStackTy::DSAVarData DVar = DSAStack->getImplicitDSA(D, Level);
 if (DVar.CKind != OMPC_shared)
   return true;
-  } while (Level >= 0);
+  } while (Level > 0);
 }
   }
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86819: [PowerPC][Power10] Implementation of 128-bit Binary Vector Rotate builtins

2020-08-31 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 289064.
Conanap added a comment.

Included extra test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86819

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-vector-rotate.ll

Index: llvm/test/CodeGen/PowerPC/p10-vector-rotate.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/p10-vector-rotate.ll
@@ -0,0 +1,75 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; This test case aims to test the builtins for vector rotate instructions
+; on Power10.
+
+
+define <1 x i128> @test_vrlq(<1 x i128> %x, <1 x i128> %y) {
+; CHECK-LABEL: test_vrlq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vrlq v2, v3, v2
+; CHECK-NEXT:blr
+  %shl.i = shl <1 x i128> %y, %x
+  %sub.i = sub <1 x i128> , %x
+  %lshr.i = lshr <1 x i128> %y, %sub.i
+  %tmp = or <1 x i128> %shl.i, %lshr.i
+  ret <1 x i128> %tmp
+}
+
+define <1 x i128> @test_vrlq_cost_mult8(<1 x i128> %x) {
+; CHECK-LABEL: test_vrlq_cost_mult8:
+; CHECK: # %bb.0:
+; CHECK: vrlq v2, v3, v2
+; CHECK-NEXT: blr
+  %shl.i = shl <1 x i128> , %x
+  %sub.i = sub <1 x i128> , %x
+  %lshr.i = lshr <1 x i128> , %sub.i
+  %tmp = or <1 x i128> %shl.i, %lshr.i
+  ret <1 x i128> %tmp
+}
+
+define <1 x i128> @test_vrlq_cost_non_mult8(<1 x i128> %x) {
+; CHECK-LABEL: test_vrlq_cost_non_mult8:
+; CHECK: # %bb.0:
+; CHECK: vrlq v2, v3, v2
+; CHECK-NEXT: blr
+  %shl.i = shl <1 x i128> , %x
+  %sub.i = sub <1 x i128> , %x
+  %lshr.i = lshr <1 x i128> , %sub.i
+  %tmp = or <1 x i128> %shl.i, %lshr.i
+  ret <1 x i128> %tmp
+}
+
+; Function Attrs: nounwind readnone
+define <1 x i128> @test_vrlqmi(<1 x i128> %a, <1 x i128> %b, <1 x i128> %c) {
+; CHECK-LABEL: test_vrlqmi:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vrlqmi v3, v2, v4
+; CHECK-NEXT:vmr v2, v3
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call <1 x i128> @llvm.ppc.altivec.vrlqmi(<1 x i128> %a, <1 x i128> %c, <1 x i128> %b)
+  ret <1 x i128> %tmp
+}
+
+; Function Attrs: nounwind readnone
+define <1 x i128> @test_vrlqnm(<1 x i128> %a, <1 x i128> %b, <1 x i128> %c) {
+; CHECK-LABEL: test_vrlqnm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vrlqnm v2, v2, v3
+; CHECK-NEXT:xxland v2, v2, v4
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <1 x i128> @llvm.ppc.altivec.vrlqnm(<1 x i128> %a, <1 x i128> %b)
+  %tmp = and <1 x i128> %0, %c
+  ret <1 x i128> %tmp
+}
+
+; Function Attrs: nounwind readnone
+declare <1 x i128> @llvm.ppc.altivec.vrlqmi(<1 x i128>, <1 x i128>, <1 x i128>)
+
+; Function Attrs: nounwind readnone
+declare <1 x i128> @llvm.ppc.altivec.vrlqnm(<1 x i128>, <1 x i128>)
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -1285,19 +1285,25 @@
"vcmpuq $BF, $vA, $vB", IIC_VecGeneral, []>;
   def VCMPSQ : VXForm_BF3_VAB5<321, (outs crrc:$BF), (ins vrrc:$vA, vrrc:$vB),
"vcmpsq $BF, $vA, $vB", IIC_VecGeneral, []>;
-  def VRLQNM : VX1_VT5_VA5_VB5<325, "vrlqnm", []>;
-  def VRLQMI : VXForm_1<69, (outs vrrc:$vD),
-(ins vrrc:$vA, vrrc:$vB, vrrc:$vDi),
-"vrlqmi $vD, $vA, $vB", IIC_VecFP, []>,
-RegConstraint<"$vDi = $vD">, NoEncode<"$vDi">;
   def VSLQ : VX1_VT5_VA5_VB5<261, "vslq", []>;
   def VSRAQ : VX1_VT5_VA5_VB5<773, "vsraq", []>;
   def VSRQ : VX1_VT5_VA5_VB5<517, "vsrq", []>;
-  def VRLQ : VX1_VT5_VA5_VB5<5, "vrlq", []>;
   def XSCVQPUQZ : X_VT5_XO5_VB5<63, 0, 836, "xscvqpuqz", []>;
   def XSCVQPSQZ : X_VT5_XO5_VB5<63, 8, 836, "xscvqpsqz", []>;
   def XSCVUQQP : X_VT5_XO5_VB5<63, 3, 836, "xscvuqqp", []>;
   def XSCVSQQP : X_VT5_XO5_VB5<63, 11, 836, "xscvsqqp", []>;
+  def VRLQ : VX1_VT5_VA5_VB5<5, "vrlq", []>;
+  def VRLQNM : VX1_VT5_VA5_VB5<325, "vrlqnm",
+   [(set v1i128:$vD,
+   (int_ppc_altivec_vrlqnm v1i128:$vA,
+   v1i128:$vB))]>;
+  def VRLQMI : VXForm_1<69, (outs vrrc:$vD),
+(ins vrrc:$vA, vrrc:$vB, vrrc:$vDi),
+"vrlqmi $vD, $vA, $vB", IIC_VecFP,
+[(set v1i128:$vD,
+   (int_ppc_altivec_vrlqmi v1i128:$vA, v1i128:$vB,
+

Buildbot numbers for the week of 08/16/2020 - 08/22/2020

2020-08-31 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 08/16/2020 - 08/22/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from green to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername|  was_red
--+--
 clang-s390x-linux-lnt| 149:47:46
 lld-sphinx-docs  | 124:29:22
 clang-sphinx-docs| 116:43:12
 sanitizer-x86_64-linux   | 73:40:40
 sanitizer-x86_64-linux-bootstrap-msan| 69:11:29
 sanitizer-x86_64-linux-fast  | 69:10:31
 lld-perf-testsuite   | 68:10:07
 clang-ppc64le-rhel   | 43:05:38
 llvm-clang-x86_64-expensive-checks-debian| 39:32:59
 clang-x86_64-debian-fast | 39:01:38
 openmp-clang-x86_64-linux-debian | 38:57:16
 clang-x86_64-debian-new-pass-manager-fast| 38:53:22
 openmp-gcc-x86_64-linux-debian   | 38:50:29
 clang-cmake-armv8-lld| 30:25:52
 clang-cmake-armv7-quick  | 30:05:43
 clang-cmake-armv7-global-isel| 29:58:00
 sanitizer-windows| 26:28:36
 clang-cmake-x86_64-sde-avx512-linux  | 23:20:24
 llvm-clang-win-x-armv7l  | 22:40:23
 llvm-avr-linux   | 20:12:22
 clang-ppc64le-linux-multistage   | 19:55:11
 flang-aarch64-ubuntu | 15:46:02
 ppc64le-lld-multistage-test  | 12:38:26
 llvm-clang-x86_64-expensive-checks-ubuntu| 12:22:11
 lldb-x64-windows-ninja   | 10:44:21
 clang-ppc64le-linux  | 10:34:20
 clang-s390x-linux-multistage | 10:00:50
 clang-x64-windows-msvc   | 09:13:51
 lld-x86_64-win   | 08:20:20
 lld-x86_64-darwin| 08:08:16
 llvm-clang-x86_64-expensive-checks-win   | 07:54:01
 lldb-arm-ubuntu  | 06:18:13
 lldb-x86_64-debian   | 06:04:32
 lldb-aarch64-ubuntu  | 05:59:54
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 05:55:01
 sanitizer-x86_64-linux-bootstrap | 05:25:08
 clang-s390x-linux| 05:23:25
 sanitizer-x86_64-linux-bootstrap-ubsan   | 05:02:19
 clang-ppc64be-linux-multistage   | 04:55:54
 lld-x86_64-ubuntu-fast   | 04:55:15
 clang-with-thin-lto-ubuntu   | 04:52:18
 clang-ppc64be-linux-lnt  | 04:45:43
 clang-ppc64be-linux  | 04:39:18
 llvm-clang-win-x-aarch64 | 04:38:02
 fuchsia-x86_64-linux | 04:34:42
 clang-cmake-aarch64-full | 04:28:00
 clang-cmake-aarch64-quick| 04:26:14
 clang-cmake-x86_64-avx2-linux| 04:23:18
 clang-cmake-aarch64-global-isel  | 04:19:36
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 04:16:34
 llvm-clang-x86_64-win-fast   | 04:02:45
 mlir-windows | 04:00:18
 mlir-nvidia  | 03:04:19
 clang-ppc64le-linux-lnt  | 02:42:56
 libc-x86_64-debian-dbg   | 01:32:07
 clang-cmake-aarch64-lld  | 01:23:04
 llvm-sphinx-docs | 01:12:31
 clang-cmake-armv7-lnt| 01:04:11
 sanitizer-x86_64-linux-fuzzer| 00:48:19
 lldb-sphinx-docs | 00:46:38
 libc-x86_64-debian-dbg-asan  | 00:42:39
 clang-x86_64-linux-abi-test  | 00:37:19
 libc-x86_64-debian   | 00:34:29
 polly-x86_64-linux-test-suite| 00:34:03
 polly-x86_64-linux   | 00:32:25
 clang-aarch64-linux-build-cache  | 00:29:43
 sanitizer-x86_64-linux-android   | 00:28:09
 clang-armv7-linux-build-cache| 00:21:27
(68 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder 

Buildbot numbers for the week of 08/23/2020 - 08/29/2020

2020-08-31 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 08/23/2020 -
08/29/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from green to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
  buildername  |  was_red
---+--
 lld-perf-testsuite| 137:48:32
 llvm-clang-win-x-armv7l   | 79:44:24
 llvm-clang-win-x-aarch64  | 62:53:11
 libcxx-libcxxabi-libunwind-aarch64-linux  | 54:46:45
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions | 49:33:13
 clang-ppc64le-rhel| 42:43:30
 clang-with-lto-ubuntu | 33:11:28
 libcxx-libcxxabi-libunwind-x86_64-linux-debian| 24:22:53
 clang-s390x-linux-multistage  | 24:21:11
 clang-x86_64-debian-new-pass-manager-fast | 22:31:14
 clang-s390x-linux | 19:24:51
 llvm-clang-x86_64-expensive-checks-debian | 18:21:50
 clang-x86_64-debian-fast  | 17:43:08
 lldb-x86_64-debian| 14:59:48
 clang-ppc64le-linux-lnt   | 13:33:02
 clang-cmake-x86_64-avx2-linux | 12:25:10
 mlir-nvidia   | 11:42:29
 clang-cmake-x86_64-sde-avx512-linux   | 11:40:21
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 11:38:37
 llvm-avr-linux| 11:28:59
 clang-cmake-aarch64-lld   | 11:24:58
 clang-ppc64le-linux   | 07:32:06
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 07:19:28
 clang-ppc64be-linux   | 06:40:38
 fuchsia-x86_64-linux  | 06:19:20
 aosp-O3-polly-before-vectorizer-unprofitable  | 06:07:36
 clang-x64-windows-msvc| 06:02:55
 clang-ppc64be-linux-lnt   | 05:40:36
 clang-with-thin-lto-ubuntu| 05:22:35
 clang-cmake-armv8-lld | 05:05:20
 lld-x86_64-win| 05:03:46
 lldb-x64-windows-ninja| 04:48:10
 sanitizer-windows | 04:44:54
 sanitizer-x86_64-linux| 04:42:42
 lld-x86_64-freebsd| 04:40:45
 llvm-clang-x86_64-win-fast| 04:34:19
 mlir-windows  | 04:32:46
 llvm-clang-x86_64-expensive-checks-win| 04:32:14
 polly-x86_64-linux-test-suite | 03:56:38
 sanitizer-x86_64-linux-bootstrap-ubsan| 03:55:27
 lld-x86_64-darwin | 03:29:56
 ppc64le-lld-multistage-test   | 03:29:20
 sanitizer-x86_64-linux-fast   | 03:28:19
 sanitizer-x86_64-linux-bootstrap-msan | 03:23:10
 lld-x86_64-ubuntu-fast| 03:07:42
 sanitizer-x86_64-linux-bootstrap  | 03:03:11
 clang-ppc64be-linux-multistage| 02:40:12
 clang-cmake-aarch64-global-isel   | 02:13:32
 clang-cmake-aarch64-full  | 02:09:33
 clang-ppc64le-linux-multistage| 02:08:54
 llvm-clang-x86_64-expensive-checks-ubuntu | 01:49:50
 sanitizer-x86_64-linux-fuzzer | 01:48:25
 flang-aarch64-ubuntu  | 01:34:10
 lldb-aarch64-ubuntu   | 01:33:55
 lldb-arm-ubuntu   | 01:33:46
 clang-cmake-armv7-global-isel | 01:33:44
 clang-cmake-aarch64-quick | 01:30:53
 clang-cmake-armv7-quick   | 01:30:28
 sanitizer-ppc64be-linux   | 01:22:45
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan | 00:57:26
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu| 00:48:35
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03| 00:48:27
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14| 00:43:24
 sanitizer-x86_64-linux-android| 00:35:31
 

Buildbot numbers for the week of 08/09/2020 - 08/15/2020

2020-08-31 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 08/09/2020 - 08/15/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from green to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
buildername|  was_red
---+--
 llvm-clang-win-x-armv7l   | 116:09:14
 clang-s390x-linux-multistage  | 108:18:29
 clang-x64-windows-msvc| 107:45:48
 clang-s390x-linux | 106:20:20
 ppc64le-lld-multistage-test   | 53:44:27
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17| 38:17:45
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a| 38:13:06
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan | 38:00:15
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan | 37:53:05
 clang-with-lto-ubuntu | 23:55:26
 clang-ppc64le-rhel| 21:24:29
 clang-with-thin-lto-ubuntu| 20:56:51
 sanitizer-windows | 16:09:51
 flang-aarch64-ubuntu  | 16:05:02
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 11:16:04
 sanitizer-x86_64-linux-fast   | 08:46:31
 sanitizer-x86_64-linux-bootstrap  | 08:45:55
 polly-x86_64-linux-test-suite | 08:35:39
 clang-ppc64le-linux   | 08:30:03
 sanitizer-ppc64be-linux   | 08:19:19
 clang-cmake-aarch64-lld   | 08:08:54
 sanitizer-x86_64-linux| 07:09:11
 aosp-O3-polly-before-vectorizer-unprofitable  | 06:29:46
 mlir-nvidia   | 06:18:39
 llvm-clang-x86_64-expensive-checks-debian | 05:50:24
 llvm-clang-x86_64-expensive-checks-ubuntu | 05:33:27
 sanitizer-x86_64-linux-android| 05:21:20
 sanitizer-x86_64-linux-bootstrap-ubsan| 04:21:50
 clang-cmake-x86_64-avx2-linux | 03:46:37
 llvm-avr-linux| 03:31:32
 llvm-clang-win-x-aarch64  | 03:26:19
 clang-ppc64le-linux-lnt   | 03:19:05
 clang-ppc64le-linux-multistage| 03:05:17
 clang-cmake-aarch64-full  | 03:03:31
 clang-cmake-aarch64-quick | 03:01:12
 openmp-gcc-x86_64-linux-debian| 02:55:39
 clang-ppc64be-linux-multistage| 02:51:14
 clang-cmake-armv8-lld | 02:48:36
 clang-cmake-armv7-global-isel | 02:38:03
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 02:36:44
 clang-cmake-x86_64-sde-avx512-linux   | 02:34:21
 fuchsia-x86_64-linux  | 02:32:15
 llvm-clang-x86_64-expensive-checks-win| 02:29:05
 clang-ppc64be-linux-lnt   | 02:28:33
 lld-x86_64-win| 02:25:23
 openmp-clang-x86_64-linux-debian  | 02:24:21
 lld-x86_64-ubuntu-fast| 02:16:11
 clang-x86_64-debian-fast  | 02:16:05
 clang-x86_64-debian-new-pass-manager-fast | 02:16:01
 lld-x86_64-darwin | 02:15:25
 clang-ppc64be-linux   | 02:14:58
 clang-cmake-armv7-quick   | 02:13:41
 sanitizer-x86_64-linux-bootstrap-msan | 02:13:37
 mlir-windows  | 02:04:03
 clang-cmake-aarch64-global-isel   | 02:02:53
 sanitizer-x86_64-linux-autoconf   | 01:52:41
 sanitizer-x86_64-linux-fuzzer | 01:25:31
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions | 01:13:01
 lldb-x64-windows-ninja| 01:06:52
 clang-x86_64-linux-abi-test   | 00:47:31
 libc-x86_64-debian-dbg| 00:45:15
 lldb-x86_64-debian| 00:40:22
 clang-cmake-armv7-lnt | 00:36:36
 lldb-aarch64-ubuntu   | 00:34:40
 lldb-arm-ubuntu   | 00:32:14
 polly-x86_64-linux| 00:31:02
 llvm-clang-x86_64-win-fast| 00:26:28
 clang-armv7-linux-build-cache | 00:24:04
 

[PATCH] D77491: [Sema] Introduce BuiltinAttr, per-declaration builtin-ness

2020-08-31 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D77491#2246948 , @rjmccall wrote:

> I'd still like @rsmith to sign off here as code owner.

Generally, I'm happy with this direction.

What happens for builtins with the "t" (custom typechecking) flag, for which 
the signature is intended to have no meaning? Do we always give them builtin 
semantics, or never, or ... something else? I think it might be reasonable to 
require them to always be declared as taking unspecified arguments -- `()` in C 
and `(...)` in C++, or to simply say that the user cannot declare such 
functions themselves.




Comment at: clang/lib/Headers/intrin.h:148
 void __writemsr(unsigned long, unsigned __int64);
-static __inline__
-void *_AddressOfReturnAddress(void);
-static __inline__
-unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask);
-static __inline__
-unsigned char _BitScanReverse(unsigned long *_Index, unsigned long _Mask);
+__inline__ void *_AddressOfReturnAddress(void);
+__inline__ unsigned char _BitScanForward(unsigned long *_Index,

Does the `__inline__` here do anything for a builtin function? Can we remove it 
along with the `static`?



Comment at: clang/lib/Headers/intrin.h:200
 void __incgsword(unsigned long);
-static __inline__
-void __movsq(unsigned long long *, unsigned long long const *, size_t);
+static __inline__ void __movsq(unsigned long long *, unsigned long long const 
*,
+   size_t);

Why is `static` being removed from some of the functions in this header but not 
others?



Comment at: clang/lib/Sema/SemaDecl.cpp:9668-9694
+  // In C builtins get merged with implicitly lazily created declarations.
+  // In C++ we need to check if it's a builtin and add the BuiltinAttr here.
+  if (getLangOpts().CPlusPlus) {
+if (IdentifierInfo *II = Previous.getLookupName().getAsIdentifierInfo()) {
+  if (unsigned BuiltinID = II->getBuiltinID()) {
+FunctionDecl *D = CreateBuiltin(II, BuiltinID, NewFD->getLocation());
+

I think this needs more refinement:

* You appear to be creating and throwing away a new builtin function 
declaration (plus parameter declarations etc) each time you see a declaration 
with a matching name, even if one was already created. Given that you don't 
actually use `D` for anything other than its type, creating the declaration 
seems redundant and using `ASTContext::GetBuiltinType` would be more 
appropriate.
* There are no checks of which scope the new function is declared in; this 
appears to apply in all scopes, but some builtin names are only reserved in the 
global scope (those beginning with an underscore followed by a lowercase letter 
such as `_bittest`), so that doesn't seem appropriate. The old code in 
`FunctionDecl::getBuiltinID` checked that the declaration is given C language 
linkage (except for `_GetExceptionInfo`, which was permitted to have C++ 
language linkage), and that check still seems appropriate to me.
* The special case permitting `_GetExceptionInfo` to be declared with *any* 
type seems suspect; the old code permitted it to have different language 
linkage, not the wrong type.
* Using `typesAreCompatible` in C++-specific code is weird, since C++ doesn't 
have a notion of "compatible types".



Comment at: clang/lib/Serialization/ASTReader.cpp:975
   bool HasRevertedTokenIDToIdentifier = readBit(Bits);
-  bool HasRevertedBuiltin = readBit(Bits);
+  readBit(Bits); // Previously used to indicate reverted builtin.
   bool Poisoned = readBit(Bits);

We don't have any stability guarantees for our AST bitcode format yet; you can 
just remove this bit rather than retaining a placeholder.



Comment at: clang/test/Analysis/bstring.cpp:106
   Derived d;
-  memset(_mem, 0, sizeof(Derived));
+  memset(_mem, 0, sizeof(Derived)); // expected-warning {{'memset' will 
always overflow; destination buffer has size 4, but size argument is 8}}
   clang_analyzer_eval(d.b_mem == 0); // expected-warning{{UNKNOWN}}

This should not be recognized as a builtin, because the `memset` function is 
not `extern "C"`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77491

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


[PATCH] D84988: [Coverage] Add empty line regions to SkippedRegions

2020-08-31 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 289047.
zequanwu added a comment.

update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84988

Files:
  clang/include/clang/Lex/Lexer.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Parse/ParseStmt.cpp
  compiler-rt/test/profile/coverage_emptylines.cpp
  compiler-rt/test/profile/instrprof-set-file-object-merging.c
  compiler-rt/test/profile/instrprof-set-file-object.c
  llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Index: llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
===
--- llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -480,16 +480,23 @@
   }
 
   bool GapRegion = CR.value().Kind == CounterMappingRegion::GapRegion;
+  bool SkippedRegion =
+  CR.value().Kind == CounterMappingRegion::SkippedRegion;
 
   // Try to emit a segment for the current region.
   if (CurStartLoc == CR.value().endLoc()) {
 // Avoid making zero-length regions active. If it's the last region,
 // emit a skipped segment. Otherwise use its predecessor's count.
-const bool Skipped = (CR.index() + 1) == Regions.size();
+const bool Skipped =
+(CR.index() + 1) == Regions.size() || SkippedRegion;
 startSegment(ActiveRegions.empty() ? CR.value() : *ActiveRegions.back(),
  CurStartLoc, !GapRegion, Skipped);
+// Create a segment with last pushed regions's count at CurStartLoc.
+startSegment(ActiveRegions.empty() ? CR.value() : *ActiveRegions.back(),
+ CurStartLoc, false);
 continue;
   }
+
   if (CR.index() + 1 == Regions.size() ||
   CurStartLoc != Regions[CR.index() + 1].startLoc()) {
 // Emit a segment if the next region doesn't start at the same location
@@ -586,7 +593,7 @@
 for (unsigned I = 1, E = Segments.size(); I < E; ++I) {
   const auto  = Segments[I - 1];
   const auto  = Segments[I];
-  if (!(L.Line < R.Line) && !(L.Line == R.Line && L.Col < R.Col)) {
+  if (!(L.Line < R.Line) && !(L.Line == R.Line && L.Col <= R.Col)) {
 LLVM_DEBUG(dbgs() << " ! Segment " << L.Line << ":" << L.Col
   << " followed by " << R.Line << ":" << R.Col << "\n");
 assert(false && "Coverage segments not unique or sorted");
Index: compiler-rt/test/profile/instrprof-set-file-object.c
===
--- compiler-rt/test/profile/instrprof-set-file-object.c
+++ compiler-rt/test/profile/instrprof-set-file-object.c
@@ -24,7 +24,7 @@
 // CHECK:   12|  1|int main(int argc, const char *argv[]) {
 // CHECK:   13|  1|  if (argc < 2)
 // CHECK:   14|  0|return 1;
-// CHECK:   15|  1|
+// CHECK:   15|   |
 // CHECK:   16|  1|  FILE *F = fopen(argv[1], "w+b");
 // CHECK:   17|  1|  __llvm_profile_set_file_object(F, 0);
 // CHECK:   18|  1|  return 0;
Index: compiler-rt/test/profile/instrprof-set-file-object-merging.c
===
--- compiler-rt/test/profile/instrprof-set-file-object-merging.c
+++ compiler-rt/test/profile/instrprof-set-file-object-merging.c
@@ -31,13 +31,13 @@
 // CHECK:   14|  2|int main(int argc, const char *argv[]) {
 // CHECK:   15|  2|  if (argc < 2)
 // CHECK:   16|  0|return 1;
-// CHECK:   17|  2|
+// CHECK:   17|   |
 // CHECK:   18|  2|  FILE *F = fopen(argv[1], "r+b");
 // CHECK:   19|  2|  if (!F) {
 // CHECK:   20|   |// File might not exist, try opening with truncation
 // CHECK:   21|  1|F = fopen(argv[1], "w+b");
 // CHECK:   22|  1|  }
 // CHECK:   23|  2|  __llvm_profile_set_file_object(F, 1);
-// CHECK:   24|  2|
+// CHECK:   24|   |
 // CHECK:   25|  2|  return 0;
 // CHECK:   26|  2|}
Index: compiler-rt/test/profile/coverage_emptylines.cpp
===
--- /dev/null
+++ compiler-rt/test/profile/coverage_emptylines.cpp
@@ -0,0 +1,61 @@
+// Remove comments first.
+// RUN: sed 's/[ \t]*\/\/.*//' %s > %t.stripped.cpp
+// RUN: %clangxx_profgen -fcoverage-mapping -o %t %t.stripped.cpp
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: llvm-cov show %t -instr-profile %t.profdata -path-equivalence=/tmp,%S 2>&1 | FileCheck %s
+
+
+int main() {// CHECK:   [[# @LINE]]| 1|int main() {
+int x = 0;  // CHECK-NEXT:  [[# @LINE]]| 1|
+// CHECK-NEXT:  [[# @LINE]]|  |
+x = 1;  // 

[PATCH] D78075: [Clang][OpenMP] Added support for nowait target in CodeGen

2020-08-31 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 289044.
tianshilei1992 added a comment.

Rebased the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78075

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9385,7 +9385,8 @@
 
   assert(OutlinedFn && "Invalid outlined function!");
 
-  const bool RequiresOuterTask = D.hasClausesOfKind();
+  const bool RequiresOuterTask = D.hasClausesOfKind() ||
+ D.hasClausesOfKind();
   llvm::SmallVector CapturedVars;
   const CapturedStmt  = *D.getCapturedStmt(OMPD_target);
   auto & = [, ](CodeGenFunction ,


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9385,7 +9385,8 @@
 
   assert(OutlinedFn && "Invalid outlined function!");
 
-  const bool RequiresOuterTask = D.hasClausesOfKind();
+  const bool RequiresOuterTask = D.hasClausesOfKind() ||
+ D.hasClausesOfKind();
   llvm::SmallVector CapturedVars;
   const CapturedStmt  = *D.getCapturedStmt(OMPD_target);
   auto & = [, ](CodeGenFunction ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: [clang] 589ce5f - [DebugInfo] Move constructor homing case in shouldOmitDefinition.

2020-08-31 Thread Voss, Matthew via cfe-commits
Hi David and Amy,

This change works for PS4. Build + test passes.

Thanks,
Matthew

From: David Blaikie 
Sent: Monday, August 31, 2020 1:22 PM
To: Voss, Matthew 
Cc: Amy Huang ; cfe-commits@lists.llvm.org
Subject: Re: [clang] 589ce5f - [DebugInfo] Move constructor homing case in 
shouldOmitDefinition.



On Mon, Aug 24, 2020 at 9:32 PM Voss, Matthew via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Hi Amy,

Looks like there's some test failures on the PS4 Linux bot as a result of this 
commit. Could you take a look? If the failure persists for a while, I may need 
to revert this to unclog the bots and our internal CI.

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/73945

Was this issue resolved? The patch was reverted and an update has been posted 
(& approved by me (though looks like it hasn't been recommitted yet)) - any 
chance Amy/Matthew/etc could check there's a good chance this issue is fixed by 
that update/won't regress on the recommit.



Thanks,
Matthew

> -Original Message-
> From: cfe-commits 
> mailto:cfe-commits-boun...@lists.llvm.org>>
>  On Behalf Of Amy
> Huang via cfe-commits
> Sent: Monday, August 24, 2020 8:18 PM
> To: cfe-commits@lists.llvm.org
> Subject: [clang] 589ce5f - [DebugInfo] Move constructor homing case in
> shouldOmitDefinition.
>
>
> Author: Amy Huang
> Date: 2020-08-24T20:17:59-07:00
> New Revision: 589ce5f7050dd83fd3f7dbc182ea0fb051ece994
>
> URL: https://github.com/llvm/llvm-
> project/commit/589ce5f7050dd83fd3f7dbc182ea0fb051ece994
> DIFF: https://github.com/llvm/llvm-
> project/commit/589ce5f7050dd83fd3f7dbc182ea0fb051ece994.diff
>
> LOG: [DebugInfo] Move constructor homing case in shouldOmitDefinition.
>
> For some reason the ctor homing case was before the template
> specialization case, and could have returned false too early.
> I moved the code out into a separate function to avoid this.
>
> Also added a run line to the template specialization test. I guess all the
> -debug-info-kind=limited tests should still pass with =constructor, but
> it's probably unnecessary to test for all of those.
>
> Differential Revision: https://reviews.llvm.org/D86491
>
> Added:
>
>
> Modified:
> clang/lib/CodeGen/CGDebugInfo.cpp
> clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
>
> Removed:
>
>
>
> ##
> ##
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp
> b/clang/lib/CodeGen/CGDebugInfo.cpp
> index e3442ecd4bd5..c2929d027a1b 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.cpp
> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
> @@ -2260,6 +2260,25 @@ static bool
> hasExplicitMemberDefinition(CXXRecordDecl::method_iterator I,
>return false;
>  }
>
> +static bool canUseCtorHoming(const CXXRecordDecl *RD) {
> +  // Constructor homing can be used for classes that have at least one
> +  // constructor and have no trivial or constexpr constructors.
> +  // Skip this optimization if the class or any of its methods are
> +marked
> +  // dllimport.
> +  if (RD->isLambda() || RD->hasConstexprNonCopyMoveConstructor() ||
> +  isClassOrMethodDLLImport(RD))
> +return false;
> +
> +  if (RD->ctors().empty())
> +return false;
> +
> +  for (const auto *Ctor : RD->ctors())
> +if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
> +  return false;
> +
> +  return true;
> +}
> +
>  static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
>   bool DebugTypeExtRefs, const RecordDecl
> *RD,
>   const LangOptions ) { @@ -
> 2294,23 +2313,6 @@ static bool
> shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
>!isClassOrMethodDLLImport(CXXDecl))
>  return true;
>
> -  // In constructor debug mode, only emit debug info for a class when its
> -  // constructor is emitted. Skip this optimization if the class or any
> of
> -  // its methods are marked dllimport.
> -  //
> -  // This applies to classes that don't have any trivial constructors and
> have
> -  // at least one constructor.
> -  if (DebugKind == codegenoptions::DebugInfoConstructor &&
> -  !CXXDecl->isLambda() && !CXXDecl-
> >hasConstexprNonCopyMoveConstructor() &&
> -  !isClassOrMethodDLLImport(CXXDecl)) {
> -if (CXXDecl->ctors().empty())
> -  return false;
> -for (const auto *Ctor : CXXDecl->ctors())
> -  if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
> -return false;
> -return true;
> -  }
> -
>TemplateSpecializationKind Spec = TSK_Undeclared;
>if (const auto *SD = dyn_cast(RD))
>  Spec = SD->getSpecializationKind(); @@ -2320,6 +2322,12 @@ static
> bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
>CXXDecl->method_end()))
>  return true;
>
> +  // In constructor homing mode, only emit complete debug info for a
> + 

[PATCH] D79677: [Clang][OpenMP][OMPBuilder] (1/4) Privatize `parallel` for `OMPBuilder`

2020-08-31 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added a comment.

In D79677#2248197 , @kiranchandramohan 
wrote:

> What is the plan for this patch?

To commit it ... eventually :)
Once it (and the rest in the series) get reviewed. As it stands,  I cannot 
commit this patch without the rest in the series, and I cannot find reviewers 
for the other patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79677

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


[clang] d563d7a - [analyzer][NFC] Add `override` keyword missing from D86027

2020-08-31 Thread Hubert Tong via cfe-commits

Author: Hubert Tong
Date: 2020-08-31T17:57:22-04:00
New Revision: d563d7a7313cf47dcb24c6370a035bd803965b4e

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

LOG: [analyzer][NFC] Add `override` keyword missing from D86027

Speculative fix for `-Werror,-Wsuggest-override` build failures on
the ppc64le-lld-multistage-test bot.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp 
b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
index f1ca28ba339d..1ca53590e06c 100644
--- a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -54,7 +54,7 @@ class SmartPtrModeling
  ArrayRef Regions,
  const LocationContext *LCtx, const CallEvent *Call) const;
   void printState(raw_ostream , ProgramStateRef State, const char *NL,
-  const char *Sep) const;
+  const char *Sep) const override;
   void checkLiveSymbols(ProgramStateRef State, SymbolReaper ) const;
 
 private:



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


[PATCH] D86895: [Modules] Add stats to measure performance of building and loading modules.

2020-08-31 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: bruno, rsmith, Bigcheese.
Herald added subscribers: llvm-commits, ributzka, dexonsmith, jkorous, 
hiraditya.
Herald added projects: clang, LLVM.
vsapsai requested review of this revision.

Measure amount of high-level or fixed-cost operations performed during
building/loading modules and during header search. High-level operations
like building a module or processing a .pcm file are motivated by
previous issues where clang was re-building modules or re-reading .pcm
files unnecessarily. Fixed-cost operations like `stat` calls are tracked
because clang cannot change how long each operation takes but it can
perform fewer of such operations to improve the compile time.

Also tracking such stats over time can help us detect compile-time
regressions. Added stats are more stable than the actual measured
compilation time, so expect the detected regressions to be less noisy.

rdar://problem/55715134


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86895

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Serialization/ASTReader.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/Unix/Path.inc
  llvm/lib/Support/Windows/Path.inc

Index: llvm/lib/Support/Windows/Path.inc
===
--- llvm/lib/Support/Windows/Path.inc
+++ llvm/lib/Support/Windows/Path.inc
@@ -710,6 +710,7 @@
 }
 
 std::error_code status(const Twine , file_status , bool Follow) {
+  ++NumStatusCalls;
   SmallString<128> path_storage;
   SmallVector path_utf16;
 
@@ -742,11 +743,13 @@
 }
 
 std::error_code status(int FD, file_status ) {
+  ++NumStatusCalls;
   HANDLE FileHandle = reinterpret_cast(_get_osfhandle(FD));
   return getStatus(FileHandle, Result);
 }
 
 std::error_code status(file_t FileHandle, file_status ) {
+  ++NumStatusCalls;
   return getStatus(FileHandle, Result);
 }
 
Index: llvm/lib/Support/Unix/Path.inc
===
--- llvm/lib/Support/Unix/Path.inc
+++ llvm/lib/Support/Unix/Path.inc
@@ -736,6 +736,7 @@
 }
 
 std::error_code status(const Twine , file_status , bool Follow) {
+  ++NumStatusCalls;
   SmallString<128> PathStorage;
   StringRef P = Path.toNullTerminatedStringRef(PathStorage);
 
@@ -745,6 +746,7 @@
 }
 
 std::error_code status(int FD, file_status ) {
+  ++NumStatusCalls;
   struct stat Status;
   int StatRet = ::fstat(FD, );
   return fillStatus(StatRet, Status, Result);
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -12,6 +12,7 @@
 
 #include "llvm/Support/Path.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Errc.h"
@@ -31,6 +32,10 @@
 using namespace llvm;
 using namespace llvm::support::endian;
 
+#define DEBUG_TYPE "file-system"
+
+ALWAYS_ENABLED_STATISTIC(NumStatusCalls, "Number of `status` calls.");
+
 namespace {
   using llvm::StringRef;
   using llvm::sys::path::is_separator;
Index: llvm/lib/Support/MemoryBuffer.cpp
===
--- llvm/lib/Support/MemoryBuffer.cpp
+++ llvm/lib/Support/MemoryBuffer.cpp
@@ -12,6 +12,7 @@
 
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Config/config.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Errno.h"
@@ -34,6 +35,12 @@
 #endif
 using namespace llvm;
 
+#define DEBUG_TYPE "memory-buffer"
+
+ALWAYS_ENABLED_STATISTIC(NumMmapFile, "Number of mmap-ed files.");
+ALWAYS_ENABLED_STATISTIC(NumAllocFile,
+ "Number of files read into allocated memory buffer.");
+
 //===--===//
 // MemoryBuffer implementation itself.
 //===--===//
@@ -449,8 +456,10 @@
   // buffer by copying off the stream.
   sys::fs::file_type Type = Status.type();
   if (Type != sys::fs::file_type::regular_file &&
-  Type != sys::fs::file_type::block_file)
+  Type != sys::fs::file_type::block_file) {
+++NumAllocFile;
 return getMemoryBufferForStream(FD, Filename);
+  }
 
   FileSize = Status.getSize();
 }
@@ -463,8 +472,10 @@
 std::unique_ptr Result(
 new (NamedBufferAlloc(Filename)) MemoryBufferMMapFile(
 RequiresNullTerminator, FD, MapSize, Offset, EC));
-if (!EC)
+if (!EC) {
+  ++NumMmapFile;
   return std::move(Result);
+}
   }
 
   auto Buf = WritableMemoryBuffer::getNewUninitMemBuffer(MapSize, Filename);
@@ -475,6 +486,7 @@
   }
 
   // Read until EOF, zero-initialize the rest.
+  ++NumAllocFile;
   MutableArrayRef ToRead = Buf->getBuffer();
   while 

[PATCH] D86707: [SystemZ][z/OS] Adding initial toolchain for z/OS

2020-08-31 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

LGTM with minor comments.




Comment at: clang/lib/Driver/ToolChains/ZOS.cpp:15
+
+using namespace clang::driver;
+using namespace clang::driver::toolchains;

There should be no need for this using directive. The lookup following the 
//declarator-id// in the declarations should operate in the context of the 
namespace that "owns" the function. There's a chance it's needed because of 
MSVC build problems though.



Comment at: clang/lib/Driver/ToolChains/ZOS.cpp:18
+using namespace llvm::opt;
+using namespace clang;
+

Same comment.



Comment at: clang/lib/Driver/ToolChains/ZOS.h:25
+
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }

abhina.sreeskantharajan wrote:
> hubert.reinterpretcast wrote:
> > According to the RFC re: LLVM on z/OS, the initial support in LLVM for z/OS 
> > is only for XPLink. My understanding is that all XPLink applications are 
> > DLL-enabled. Does being DLL-enabled not imply that the code is 
> > position-independent?
> > 
> > I understand that the value of the `__DLL__` predefined macro from the XL C 
> > compiler does not reflect the implicit DLL-enablement of XPLink code; 
> > however, I also note that the same compiler claims falsely that `Option 
> > NODLL is ignored because option XPLINK is specified` when `-qnodll` does 
> > actually suppress the effect of an earlier `-qdll` in causing `__DLL__` to 
> > be defined.
> This is not always true because we do not require code to be PIC on z/OS, 
> even for XPLink applications. Absolute addresses may be present in code 
> sections for easier access (e.g. in calls to linkages, branch tables). We 
> also may link to libraries that contain non-PIC code.
Got it (I think). Load-time relocations can occur within the program text 
instead of using PIC code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86707

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


[PATCH] D77491: [Sema] Introduce BuiltinAttr, per-declaration builtin-ness

2020-08-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Serialization/ASTWriter.cpp:3387
 Bits = (Bits << 1) | unsigned(II->isPoisoned());
-Bits = (Bits << 1) | unsigned(II->hasRevertedBuiltin());
+Bits <<= 1; // Previously used to indicate reverted builtin.
 Bits = (Bits << 1) | unsigned(II->hasRevertedTokenIDToIdentifier());

Clang bitcode isn't really a stable format, it's fine to just drop this bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77491

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


[PATCH] D79677: [Clang][OpenMP][OMPBuilder] (1/4) Privatize `parallel` for `OMPBuilder`

2020-08-31 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan added a comment.

What is the plan for this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79677

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


[PATCH] D85619: [clang][OpenMP][OMPBuilder] Use OMPBuilder to CG `omp single`

2020-08-31 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan added a comment.

What is the plan for this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85619

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


[PATCH] D85924: [clang][feature] Add cxx_abi_relative_vtable feature

2020-08-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

*ping* @aaron.ballman. Would you be able to sign off on this? Otherwise, I'll 
probably commit this in the next few days.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85924

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


[PATCH] D85473: [Clang] Add option to allow marking pass-by-value args as noalias.

2020-08-31 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85473

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


[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-08-31 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Thank you very much for review!

I have amended this diff based on the latest comment by @scanon.

So, I will land D85031  and then D85032: 
[builtins] Make divXf3 handle denormal results 
 if there are no other objections.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85031

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


[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-08-31 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 289022.
atrosinenko added a comment.

Update after the latest comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85031

Files:
  compiler-rt/lib/builtins/divdf3.c
  compiler-rt/lib/builtins/divsf3.c
  compiler-rt/lib/builtins/divtf3.c
  compiler-rt/lib/builtins/fp_div_impl.inc
  compiler-rt/lib/builtins/fp_lib.h
  compiler-rt/lib/builtins/int_util.h
  compiler-rt/test/builtins/Unit/divdf3_test.c

Index: compiler-rt/test/builtins/Unit/divdf3_test.c
===
--- compiler-rt/test/builtins/Unit/divdf3_test.c
+++ compiler-rt/test/builtins/Unit/divdf3_test.c
@@ -92,5 +92,13 @@
 if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;
 
+// some misc test cases obtained by fuzzing against h/w implementation
+if (test__divdf3(0x1.fdc239dd64735p-658, -0x1.fff9364c0843fp-948, UINT64_C(0xd20fdc8fc0ceffb1)))
+  return 1;
+if (test__divdf3(-0x1.78abb261d47c8p+794, 0x1.fb01d537cc5aep+266, UINT64_C(0xe0e7c6148ffc23e3)))
+  return 1;
+if (test__divdf3(-0x1.da7dfe6048b8bp-875, 0x1.ffc7ea3ff60a4p-610, UINT64_C(0xaf5dab1fe0269e2a)))
+  return 1;
+
 return 0;
 }
Index: compiler-rt/lib/builtins/int_util.h
===
--- compiler-rt/lib/builtins/int_util.h
+++ compiler-rt/lib/builtins/int_util.h
@@ -28,4 +28,20 @@
 #define COMPILE_TIME_ASSERT2(expr, cnt)\
   typedef char ct_assert_##cnt[(expr) ? 1 : -1] UNUSED
 
+// Force unrolling the code specified to be repeated N times.
+#define REPEAT_0_TIMES(code_to_repeat) /* do nothing */
+#define REPEAT_1_TIMES(code_to_repeat) code_to_repeat
+#define REPEAT_2_TIMES(code_to_repeat) \
+  REPEAT_1_TIMES(code_to_repeat)   \
+  code_to_repeat
+#define REPEAT_3_TIMES(code_to_repeat) \
+  REPEAT_2_TIMES(code_to_repeat)   \
+  code_to_repeat
+#define REPEAT_4_TIMES(code_to_repeat) \
+  REPEAT_3_TIMES(code_to_repeat)   \
+  code_to_repeat
+
+#define REPEAT_N_TIMES_(N, code_to_repeat) REPEAT_##N##_TIMES(code_to_repeat)
+#define REPEAT_N_TIMES(N, code_to_repeat) REPEAT_N_TIMES_(N, code_to_repeat)
+
 #endif // INT_UTIL_H
Index: compiler-rt/lib/builtins/fp_lib.h
===
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -40,9 +40,12 @@
 
 #if defined SINGLE_PRECISION
 
+typedef uint16_t half_rep_t;
 typedef uint32_t rep_t;
+typedef uint64_t twice_rep_t;
 typedef int32_t srep_t;
 typedef float fp_t;
+#define HALF_REP_C UINT16_C
 #define REP_C UINT32_C
 #define significandBits 23
 
@@ -58,9 +61,11 @@
 
 #elif defined DOUBLE_PRECISION
 
+typedef uint32_t half_rep_t;
 typedef uint64_t rep_t;
 typedef int64_t srep_t;
 typedef double fp_t;
+#define HALF_REP_C UINT32_C
 #define REP_C UINT64_C
 #define significandBits 52
 
@@ -102,9 +107,11 @@
 #elif defined QUAD_PRECISION
 #if __LDBL_MANT_DIG__ == 113 && defined(__SIZEOF_INT128__)
 #define CRT_LDBL_128BIT
+typedef uint64_t half_rep_t;
 typedef __uint128_t rep_t;
 typedef __int128_t srep_t;
 typedef long double fp_t;
+#define HALF_REP_C UINT64_C
 #define REP_C (__uint128_t)
 // Note: Since there is no explicit way to tell compiler the constant is a
 // 128-bit integer, we let the constant be casted to 128-bit integer
Index: compiler-rt/lib/builtins/fp_div_impl.inc
===
--- /dev/null
+++ compiler-rt/lib/builtins/fp_div_impl.inc
@@ -0,0 +1,414 @@
+//===-- fp_div_impl.inc - Floating point division -*- 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
+//
+//===--===//
+//
+// This file implements soft-float division with the IEEE-754 default
+// rounding (to nearest, ties to even).
+//
+//===--===//
+
+#include "fp_lib.h"
+
+// The __divXf3__ function implements Newton-Raphson floating point division.
+// It uses 3 iterations for float32, 4 for float64 and 5 for float128,
+// respectively. Due to number of significant bits being roughly doubled
+// every iteration, the two modes are supported: N full-width iterations (as
+// it is done for float32 by default) and (N-1) half-width iteration plus one
+// final full-width iteration. It is expected that half-width integer
+// operations (w.r.t 

Re: [clang] 589ce5f - [DebugInfo] Move constructor homing case in shouldOmitDefinition.

2020-08-31 Thread David Blaikie via cfe-commits
On Mon, Aug 24, 2020 at 9:32 PM Voss, Matthew via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Amy,
>
> Looks like there's some test failures on the PS4 Linux bot as a result of
> this commit. Could you take a look? If the failure persists for a while, I
> may need to revert this to unclog the bots and our internal CI.
>
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/73945


Was this issue resolved? The patch was reverted and an update has been
posted (& approved by me (though looks like it hasn't been recommitted
yet)) - any chance Amy/Matthew/etc could check there's a good chance this
issue is fixed by that update/won't regress on the recommit.


>
>
> Thanks,
> Matthew
>
> > -Original Message-
> > From: cfe-commits  On Behalf Of Amy
> > Huang via cfe-commits
> > Sent: Monday, August 24, 2020 8:18 PM
> > To: cfe-commits@lists.llvm.org
> > Subject: [clang] 589ce5f - [DebugInfo] Move constructor homing case in
> > shouldOmitDefinition.
> >
> >
> > Author: Amy Huang
> > Date: 2020-08-24T20:17:59-07:00
> > New Revision: 589ce5f7050dd83fd3f7dbc182ea0fb051ece994
> >
> > URL: https://github.com/llvm/llvm-
> > project/commit/589ce5f7050dd83fd3f7dbc182ea0fb051ece994
> > DIFF: https://github.com/llvm/llvm-
> > project/commit/589ce5f7050dd83fd3f7dbc182ea0fb051ece994.diff
> >
> > LOG: [DebugInfo] Move constructor homing case in shouldOmitDefinition.
> >
> > For some reason the ctor homing case was before the template
> > specialization case, and could have returned false too early.
> > I moved the code out into a separate function to avoid this.
> >
> > Also added a run line to the template specialization test. I guess all
> the
> > -debug-info-kind=limited tests should still pass with =constructor, but
> > it's probably unnecessary to test for all of those.
> >
> > Differential Revision: https://reviews.llvm.org/D86491
> >
> > Added:
> >
> >
> > Modified:
> > clang/lib/CodeGen/CGDebugInfo.cpp
> > clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
> >
> > Removed:
> >
> >
> >
> >
> ##
> > ##
> > diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp
> > b/clang/lib/CodeGen/CGDebugInfo.cpp
> > index e3442ecd4bd5..c2929d027a1b 100644
> > --- a/clang/lib/CodeGen/CGDebugInfo.cpp
> > +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
> > @@ -2260,6 +2260,25 @@ static bool
> > hasExplicitMemberDefinition(CXXRecordDecl::method_iterator I,
> >return false;
> >  }
> >
> > +static bool canUseCtorHoming(const CXXRecordDecl *RD) {
> > +  // Constructor homing can be used for classes that have at least one
> > +  // constructor and have no trivial or constexpr constructors.
> > +  // Skip this optimization if the class or any of its methods are
> > +marked
> > +  // dllimport.
> > +  if (RD->isLambda() || RD->hasConstexprNonCopyMoveConstructor() ||
> > +  isClassOrMethodDLLImport(RD))
> > +return false;
> > +
> > +  if (RD->ctors().empty())
> > +return false;
> > +
> > +  for (const auto *Ctor : RD->ctors())
> > +if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
> > +  return false;
> > +
> > +  return true;
> > +}
> > +
> >  static bool shouldOmitDefinition(codegenoptions::DebugInfoKind
> DebugKind,
> >   bool DebugTypeExtRefs, const RecordDecl
> > *RD,
> >   const LangOptions ) { @@ -
> > 2294,23 +2313,6 @@ static bool
> > shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
> >!isClassOrMethodDLLImport(CXXDecl))
> >  return true;
> >
> > -  // In constructor debug mode, only emit debug info for a class when
> its
> > -  // constructor is emitted. Skip this optimization if the class or any
> > of
> > -  // its methods are marked dllimport.
> > -  //
> > -  // This applies to classes that don't have any trivial constructors
> and
> > have
> > -  // at least one constructor.
> > -  if (DebugKind == codegenoptions::DebugInfoConstructor &&
> > -  !CXXDecl->isLambda() && !CXXDecl-
> > >hasConstexprNonCopyMoveConstructor() &&
> > -  !isClassOrMethodDLLImport(CXXDecl)) {
> > -if (CXXDecl->ctors().empty())
> > -  return false;
> > -for (const auto *Ctor : CXXDecl->ctors())
> > -  if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
> > -return false;
> > -return true;
> > -  }
> > -
> >TemplateSpecializationKind Spec = TSK_Undeclared;
> >if (const auto *SD = dyn_cast(RD))
> >  Spec = SD->getSpecializationKind(); @@ -2320,6 +2322,12 @@ static
> > bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
> >CXXDecl->method_end()))
> >  return true;
> >
> > +  // In constructor homing mode, only emit complete debug info for a
> > + class  // when its constructor is emitted.
> > +  if ((DebugKind != codegenoptions::DebugInfoConstructor) &&
> > +  canUseCtorHoming(CXXDecl))
> 

[PATCH] D84988: [Coverage] Add empty line regions to SkippedRegions

2020-08-31 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

Friendly ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84988

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


[PATCH] D86877: [Clang][Driver] Support per-target runtime directories in the bare-metal toolchain

2020-08-31 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This was discussed when `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` was introduced and 
there was a pushback against changing the driver behavior depending on the 
value of that option, so if we're going to reverse that decision for BareMetal, 
I think that deserves a broader discussion.




Comment at: clang/lib/Driver/ToolChains/BareMetal.cpp:163
+  CmdArgs.push_back(
+  Args.MakeArgString("-lclang_rt.builtins-" + getTriple().getArchName()));
+#endif

Is there a reason why BareMetal doesn't just use 
https://github.com/llvm/llvm-project/blob/master/clang/lib/Driver/ToolChain.cpp#L462
 like all other drivers, and instead re-implements the runtime library lookup 
logic?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86877

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


[PATCH] D86699: [SyntaxTree] Ignore implicit non-leaf `CXXConstructExpr`

2020-08-31 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:48-58
+static Expr *IgnoreImplicitCXXConstructExpr(Expr *E) {
+  if (auto *C = dyn_cast(E)) {
+auto NumArgs = C->getNumArgs();
+if (NumArgs == 1 || (NumArgs > 1 && isa(C->getArg(1 
{
+  auto *A = C->getArg(0);
+  if (A->getSourceRange() == E->getSourceRange())
+return A;

eduucaldas wrote:
> Should this go into `IgnoreExpr` as well?
> 
> If yes, should we unify this with the lambda inside 
> `IgnoreUnlessSpelledInSource`, thus removing the lambda and using this free 
> function instead?
That sounds like a good idea to me.



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:1749
 void test(X x, X y) {
   [[x + y]];
 }

Could you also add a test that invokes implicit conversions?

```
struct X {
  X(int);
};
void TakeX(const X&);

void test() {
  [[TakeX(1)]];
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86699

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


[PATCH] D86700: [SyntaxTree] Ignore leaf implicit `CXXConstructExpr`

2020-08-31 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:552
   [[::n::S s1]];
   [[n::S s2]];
 }

Do we have tests for calling constructors with arguments?

`n::S s3(1, 2, 3);`
`n::S s3{1, 2, 3};`

If not, please add them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86700

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


[PATCH] D85408: Let -basic-block-sections=labels emit basicblock metadata in a new .bb_addr_map section, instead of emitting special unary-encoded symbols.

2020-08-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/CodeGen/MachineBasicBlock.cpp:78
 } else {
+  auto Prefix = Ctx.getAsmInfo()->getPrivateLabelPrefix();
   CachedMCSymbol = Ctx.getOrCreateSymbol(Twine(Prefix) + "BB" +

Expand `auto`

https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable



Comment at: 
llvm/test/CodeGen/X86/basic-block-sections-labels-functions-sections.ll:33
+; CHECK-LABEL: _Z4fooTIiET_v:
+; CHECK-NEXT:  [[FOOCOMDAT_BEGIN:.+]]:
+; CHECK:   .section 
.bb_addr_map,"Go",@progbits,_Z4fooTIiET_v,comdat,.text._Z4fooTIiET_v{{$}}

Can you use a more specific pattern than `.+`? It is difficult to know which 
pattern it uses (a larger issue is that it matches spaces and possibly 
leverages a subtle property of FileCheck)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85408

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


[PATCH] D85408: Let -basic-block-sections=labels emit basicblock metadata in a new .bb_addr_map section, instead of emitting special unary-encoded symbols.

2020-08-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/docs/UsersManual.rst:1703
 
-  Controls whether Clang emits a label for each basic block.  Further, with
-  values "all" and "list=arg", each basic block or a subset of basic blocks
-  can be placed in its own unique section.
+  Controls how Clang emits text sections for basic blocks. With values "all"
+  and "list=arg", each basic block or a subset of basic blocks can be placed in

Use backquotes like below



Comment at: clang/test/CodeGen/basic-block-sections.c:3
 
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -o - < %s | FileCheck %s 
--check-prefix=PLAIN
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fbasic-block-sections=all 
-fbasic-block-sections=none -o - < %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -S -o - < %s | FileCheck 
%s --check-prefix=PLAIN
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -S 
-fbasic-block-sections=all -fbasic-block-sections=none -o - < %s | FileCheck %s 
--check-prefix=PLAIN

The triple change is unneeded. You can also just use `-triple x86_64` because 
the behavior applies to generic ELF.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85408

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


[PATCH] D82791: [lit] Improve lit's output with default settings and --verbose.

2020-08-31 Thread Julian Lettner via Phabricator via cfe-commits
yln added inline comments.



Comment at: llvm/docs/CommandGuide/lit.rst:102
+
+ Alias for ``-v``/``--verbose`` (for backwards compatibility).
 .. option:: -a, --show-all

blank line



Comment at: llvm/utils/lit/lit/OutputSettings.py:34
+ONLY_FAILING_COMMAND = CommandOutputStyle("OnlyFailing")
+UP_TO_AND_INCLUDING_FAILING_COMMAND = CommandOutputStyle("UpToAndIncluding")
+

varungandhi-apple wrote:
> yln wrote:
> > I really like the "communicating intent" part of this infrastructure.  
> > However, this is a lot of code and `if`s considering we really only have to 
> > distinguish two cases.  From your commit message:
> > 
> > - default (no flags): no script, show only failing line in command output
> > - `-v`: full script, adds 'set +x', shows command output
> > 
> > Am I missing something or could everything be keyed off a single verbose 
> > (reading from the code below `showAllOutput` implies verbose) flag.  Do we 
> > anticipate other combinations being useful? (In general I would argue for 
> > striving for the simplest implementation that gives us what we currently 
> > want and not try to anticipate future extensions.)
> > 
> > Have you considered (or started out with) just using a single verbose flag 
> > to base your decisions in the implementation functions?  
> Not sure what you mean by two cases, I think there are three cases:
> 
> 1. Quiet -> Corresponds on `NO_COMMAND`
> 2. Default (no quiet, no verbose) -> Corresponds to `ONLY_FAILING`.
> 3. Verbose -> Corresponds to `UP_TO_AND_INCLUDING_FAILING`.
> 
> Since there is a 1-1 correspondence, we _could_ compare quiet vs (!quiet && 
> !verbose) vs verbose in `make_command_output`. I chose not to do that because 
> I figured this makes the intent clearer by distinguishing between 
> user-specified options and derived options.
> 
> Does that make sense? Would you still prefer that I get rid of this?
Okay, I agree now that having an enum-like thing is really nice because we can 
give it a good explanatory name.

Can we roll the following options into one enum-like `OutputStyle.XXX` 
corresponding to our 3 cases: "quiet, default/only_failing, 
verbose/up_to_first_failing"; since the user's can't configure them 
individually.

I imagine the following things
`opts.show_output_on_failure`, `opts.script_output_style`, 
`opts.command_output_style`, and `opts.quiet` being replaced with 
`opts.output_style`



Comment at: llvm/utils/lit/lit/TestRunner.py:1503-1508
+Returns a pair of:
+- The index in ``output_str`` pointing to immediately after the preceding
+  newline, i.e. the start of the RUN line, before any shell-specific
+  prefix.
+- The matched substring itself, including the number at the end,
+  starting with 'RUN', skipping the shell-specific prefix.

varungandhi-apple wrote:
> yln wrote:
> > Why use a complicated parser-like return value? Our only caller below could 
> > just receive the potentially found RUN line.
> Sorry, it's not super clear because in this revision, there is only one 
> caller, which could do with just using the index. However, the highlighting 
> patch (which comes right after this logically) ends up making use of the 
> substring. The line of reasoning is:
> 
> 1. A substring by itself is not good enough (and hence `make_command_output` 
> in this patch makes use of the first index return value), because we want to 
> distinguish the case `line_start == 0` from the case `line_start > 0` by 
> printing `Command Output (stderr)` instead of `Command Output (stderr, 
> truncated)` when `line_start == 0`.
> 2. An index by itself could be "good enough", but we try to be smarter in the 
> highlighting patch (https://reviews.llvm.org/D82811) by not highlighting the 
> shell-specific prefix, and starting highlighting from the "RUN", which 
> `make_script_output` makes use of.
> 
> Does that make sense? I decided against splitting changes to this function 
> into two revisions and have the full functionality in the first iteration 
> because I felt like that would create more churn with the tests and the 
> implementation, but I see how it can be confusing as to why two 
> related-but-slightly-different-values are being returned simultaneously when 
> only one is really being used in this patch.
Yes, please implement it in the "simplest way possible" for the current 
functionality without anticipating future requirements.  We can always make it 
more complex if required for a future feature, but's it's harder to "see" that 
there is opportunity for simplification once the code is there.

Also, another reviewer might suggest a solution you haven't thought about.

For example, could highlighting be implemented via (without worrying about 
indexes)?
```
s = get_important_bits(full_output)
s_highlighted = '{}'.format(s)
highlighted_output = full_output.replace(s, s_highlighted)
```





Comment at: 

[PATCH] D86369: [Sema][MSVC] warn at dynamic_cast when /GR- is given

2020-08-31 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added inline comments.



Comment at: clang/lib/Sema/SemaCast.cpp:895
+  if (!Self.getLangOpts().RTTIData) {
+bool isMSVC = Self.getDiagnostics().getDiagnosticOptions().getFormat() ==
+  DiagnosticOptions::MSVC;

hans wrote:
> zequanwu wrote:
> > hans wrote:
> > > zequanwu wrote:
> > > > hans wrote:
> > > > > I'm not sure isMSVC is the best name (it's not clear what aspect is 
> > > > > MSVC exactly -- in this case it's the diagnostics format).
> > > > > 
> > > > > It's possible to target MSVC both with clang-cl and with regular 
> > > > > clang.
> > > > > 
> > > > > For example, one could use
> > > > > 
> > > > >   clang-cl /c /tmp/a.cpp
> > > > > 
> > > > > or
> > > > > 
> > > > >   clang -c /tmp/a.cpp -target i686-pc-windows-msvc19.11.0 
> > > > > -fms-extensions
> > > > > 
> > > > > 
> > > > > My understanding is that the purpose of "isMSVC" here is to try and 
> > > > > detect if we're using clang-cl or clang so that the diagnostic can 
> > > > > say "/GR-" or "-fno-rtti-data". So maybe it's better to call it 
> > > > > "isClangCL" or something like that.
> > > > > 
> > > > > Also, I don't think we should check "isMSVC" in the if-statement 
> > > > > below. We want the warning to fire both when using clang and 
> > > > > clang-cl: as long as -fno-rtti-data or /GR- is used, the warning 
> > > > > makes sense.
> > > > > 
> > > > > So I think the code could be more like:
> > > > > 
> > > > > ```
> > > > > if (!Self.getLangOpts().RTTIData && !DestPointee->isVoidType()) {
> > > > >   bool isClangCL = ...;
> > > > >   Self.Diag(...) << isClangCL;
> > > > > }
> > > > > ```
> > > > MSVC will warn even if the DestPointee is void type. What I thought is 
> > > > if invoked by clang-cl warn regardless of DeskPointee type. If invoked 
> > > > by clang, warn if it's not void type. 
> > > > https://godbolt.org/z/475q5v. I noticed MSVC won't warn at typeid if 
> > > > /GR- is given. Probably I should remove the warning in typeid.
> > > If it's true the casting to void* doesn't need RTTI data (I think it is, 
> > > but would be good to verify), then it doesn't make sense to warn. We 
> > > don't have to follow MSVC's behavior when it doesn't make sense :)
> > > 
> > > Similar reasoning for typeid() - I assume it won't work with /GR- also 
> > > with MSVC, so warning about it probably makes sense.
> > In clang, I believe that dynamic_cast to void* doesn't use RTTI data: 
> > https://godbolt.org/z/Kbr7Mq
> > Looks like MSVC only warns if the operand of typeid is not pointer: 
> > https://godbolt.org/z/chcMcn
> > 
> When targeting Windows, dynamic_cast to void* is implemented with in a 
> runtime function, RTCastToVoid: https://godbolt.org/z/Kecr7z
> I wonder if that uses RTTI data internally though...
> 
> For typeid() I guess it would also warn on references? Maybe we should do the 
> same.
Couldn't find if `__RTCastToVoid` uses RTTI data internally.

For typeid(), it also warn on references. But the behavior is a bit weird 
(https://godbolt.org/z/jn4Pjx). Seems like it warns only when dereferencing a 
pointer or argument is a reference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86369

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


[PATCH] D83984: Explicitly use utf-8 in send_string

2020-08-31 Thread Tom Rix via Phabricator via cfe-commits
trixirt added a comment.

Yes, this break on py2, and py3 the change is a noop


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83984

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


[PATCH] D86796: [Sema] Address-space sensitive index check for unbounded arrays

2020-08-31 Thread Chris Hamilton via Phabricator via cfe-commits
chrish_ericsson_atx updated this revision to Diff 288995.
chrish_ericsson_atx added a comment.

Corrected formatting (per git-clang-format)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86796

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/const-eval.c
  clang/test/Sema/unbounded-array-bounds.c
  clang/test/SemaCXX/constant-expression-cxx1y.cpp

Index: clang/test/SemaCXX/constant-expression-cxx1y.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx1y.cpp
+++ clang/test/SemaCXX/constant-expression-cxx1y.cpp
@@ -1018,8 +1018,9 @@
 }
 
 constexpr void PR28739(int n) { // expected-error {{never produces a constant}}
-  int *p = 
+  int *p =   // expected-note {{declared here}}
   p += (__int128)(unsigned long)-1; // expected-note {{cannot refer to element 18446744073709551615 of non-array object in a constant expression}}
+  // expected-warning@-1 {{refers past the last possible element}}
 }
 
 constexpr void Void(int n) {
Index: clang/test/Sema/unbounded-array-bounds.c
===
--- /dev/null
+++ clang/test/Sema/unbounded-array-bounds.c
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-X86-ADDR64 %s  \
+// RUN:  --implicit-check-not 'past the last possible element'
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu   -fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-I386-ADDR32 %s \
+// RUN:  --implicit-check-not 'past the last possible element'
+// RUN: %clang_cc1 -triple avr-pc-linux-gnu-fsyntax-only %s 2>&1 | FileCheck --check-prefix=CHECK-AVR-ADDR16 %s  \
+// RUN:  --implicit-check-not 'past the last possible element'
+
+struct S {
+  long long a;
+  char b;
+  long long c;
+  short d;
+};
+
+struct S s[];
+
+void f1() {
+  ++s[3].a;
+  ++s[7073650413200313099].b;
+  // CHECK-X86-ADDR64:  :[[@LINE-1]]:5: warning: {{.*}} past the last possible element {{.*}} in 64-bit {{.*}} (max possible 576460752303423488 elements)
+  // CHECK-I386-ADDR32: :[[@LINE-2]]:5: warning: {{.*}} past the last possible element {{.*}} in 32-bit {{.*}} (max possible 178956970 elements)
+  // CHECK-AVR-ADDR16:  :[[@LINE-3]]:5: warning: {{.*}} past the last possible element {{.*}} in 16-bit {{.*}} (max possible 3276 elements)
+  ++s[7073650].c;
+  // CHECK-AVR-ADDR16:  :[[@LINE-1]]:5: warning: {{.*}} past the last possible element {{.*}} in 16-bit {{.*}} (max possible 3276 elements)
+}
+
+long long ll[];
+
+void f2() {
+  ++ll[3];
+  ++ll[2705843009213693952];
+  // CHECK-X86-ADDR64:  :[[@LINE-1]]:5: warning: {{.*}} past the last possible element {{.*}} in 64-bit {{.*}} (max possible 2305843009213693952 elements)
+  // CHECK-I386-ADDR32: :[[@LINE-2]]:5: warning: {{.*}} past the last possible element {{.*}} in 32-bit {{.*}} (max possible 536870912 elements)
+  // CHECK-AVR-ADDR16:  :[[@LINE-3]]:5: warning: {{.*}} past the last possible element {{.*}} in 16-bit {{.*}} (max possible 8192 elements)
+  ++ll[847073650];
+  // CHECK-I386-ADDR32: :[[@LINE-1]]:5: warning: {{.*}} past the last possible element {{.*}} in 32-bit {{.*}} (max possible 536870912 elements)
+  // CHECK-AVR-ADDR16:  :[[@LINE-2]]:5: warning: {{.*}} past the last possible element {{.*}} in 16-bit {{.*}} (max possible 8192 elements)
+}
+
+void f3(struct S p[]) {
+  ++p[3].a;
+  ++p[7073650413200313099].b;
+  // CHECK-X86-ADDR64:  :[[@LINE-1]]:5: warning: {{.*}} past the last possible element {{.*}} in 64-bit {{.*}} (max possible 576460752303423488 elements)
+  // CHECK-I386-ADDR32: :[[@LINE-2]]:5: warning: {{.*}} past the last possible element {{.*}} in 32-bit {{.*}} (max possible 178956970 elements)
+  // CHECK-AVR-ADDR16:  :[[@LINE-3]]:5: warning: {{.*}} past the last possible element {{.*}} in 16-bit {{.*}} (max possible 3276 elements)
+  ++p[7073650].c;
+  // CHECK-AVR-ADDR16:  :[[@LINE-1]]:5: warning: {{.*}} past the last possible element {{.*}} in 16-bit {{.*}} (max possible 3276 elements)
+}
+
+void f4(struct S *p) {
+  p += 3;
+  p += 7073650413200313099;
+  // CHECK-X86-ADDR64:  :[[@LINE-1]]:3: warning: {{.*}} past the last possible element {{.*}} in 64-bit {{.*}} (max possible 576460752303423488 elements)
+  // CHECK-I386-ADDR32: :[[@LINE-2]]:3: warning: {{.*}} past the last possible element {{.*}} in 32-bit {{.*}} (max possible 178956970 elements)
+  // CHECK-AVR-ADDR16:  :[[@LINE-3]]:3: warning: {{.*}} past the last possible element {{.*}} in 16-bit {{.*}} (max possible 3276 elements)
+  p += 7073650;
+  // CHECK-AVR-ADDR16:  :[[@LINE-1]]:3: warning: {{.*}} past the last possible element {{.*}} in 16-bit {{.*}} (max possible 3276 elements)
+}
Index: clang/test/Sema/const-eval.c
===
--- 

[PATCH] D86621: [clang][Sparc] Default to -mcpu=v9 for SparcV8 on Solaris

2020-08-31 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

And notably _doesn't_ define the V8 macros, which this patch then reintroduces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86621

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


[PATCH] D86621: [clang][Sparc] Default to -mcpu=v9 for SparcV8 on Solaris

2020-08-31 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 requested changes to this revision.
jrtc27 added a comment.
This revision now requires changes to proceed.

GCC on Linux defines `__sparc_v9__` even with `-m32`. I don't know what Solaris 
does but please don't break other operating systems just because Solaris has 
broken headers that conflate the CPU and the ABI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86621

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


[PATCH] D86621: [clang][Sparc] Default to -mcpu=v9 for SparcV8 on Solaris

2020-08-31 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> While the fix proper is trivial: just two lines in 
> lib/Driver/ToolChains/CommonArgs.cpp, finding the right place has been 
> nightmarishly difficult: I'd have expected handling of a Solaris/SPARC CPU 
> default in either of Solaris or SPARC specific files, but not deeply hidden 
> in common code. I've come across issues like this over and over again: 
> configuration information in LLVM is spread all over the place, difficult to 
> find or just to know that it exists.

The clang driver is messy, yes.  Other places are pretty good about this, 
mostly.

For compiler-rt, the XFAILs should probably reflect whatever config the bot is 
running.  (Alternatively, you could use UNSUPPORTED, but that doesn't seem 
warranted here.)




Comment at: clang/lib/Basic/Targets/Sparc.cpp:224
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+  }
 }

This probably should be refactored so the target-independent code generates it 
based on MaxAtomicInlineWidth, instead of duplicating it for each target.  But 
I guess you don't need to do that here.

From the other code, the `getCPUGeneration(CPU) == CG_V9` check should only 
guard the definition of __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8?



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:350
   return A->getValue();
+if (T.getArch() == llvm::Triple::sparc && T.isOSSolaris())
+  return "v9";

Do we want to make sparc and sparcel behave differently here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86621

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


[PATCH] D86027: [analyzer] Add bool operator modeling for unque_ptr

2020-08-31 Thread Nithin VR via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbc3d4d9ed783: [analyzer] Add bool operator modeling for 
unque_ptr (authored by vrnithinkumar).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86027

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/smart-ptr-text-output.cpp
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -8,12 +8,13 @@
 void clang_analyzer_warnIfReached();
 void clang_analyzer_numTimesReached();
 void clang_analyzer_eval(bool);
+void clang_analyzer_warnOnDeadSymbol(int *);
 
 void derefAfterMove(std::unique_ptr P) {
   std::unique_ptr Q = std::move(P);
   if (Q)
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
-  *Q.get() = 1; // no-warning
+  *Q.get() = 1; // expected-warning {{Dereference of null pointer [core.NullDereference]}}
   if (P)
 clang_analyzer_warnIfReached(); // no-warning
   // TODO: Report a null dereference (instead).
@@ -375,3 +376,77 @@
   std::unique_ptr P(functionReturnsRValueRef());
   P->foo();  // No warning.
 }
+
+void derefConditionOnNullPtr() {
+  std::unique_ptr P;
+  if (P)
+P->foo(); // No warning.
+  else
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefConditionOnNotNullPtr() {
+  std::unique_ptr P;
+  if (!P)
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefConditionOnValidPtr() {
+  std::unique_ptr P(new A());
+  std::unique_ptr PNull;
+  if (P)
+PNull->foo(); // expected-warning {{Dereference of null smart pointer 'PNull' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefConditionOnNotValidPtr() {
+  std::unique_ptr P(new A());
+  std::unique_ptr PNull;
+  if (!P)
+PNull->foo(); // No warning.
+}
+
+void derefConditionOnUnKnownPtr(std::unique_ptr P) {
+  if (P)
+P->foo(); // No warning.
+  else
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefOnValidPtrAfterReset(std::unique_ptr P) {
+  P.reset(new A());
+  if (!P)
+P->foo(); // No warning.
+  else
+P->foo(); // No warning.
+}
+
+void innerPointerSymbolLiveness() {
+  std::unique_ptr P(new int());
+  clang_analyzer_warnOnDeadSymbol(P.get());
+  int *RP = P.release();
+} // expected-warning{{SYMBOL DEAD}}
+
+void boolOpCreatedConjuredSymbolLiveness(std::unique_ptr P) {
+  if (P) {
+int *X = P.get();
+clang_analyzer_warnOnDeadSymbol(X);
+  }
+} // expected-warning{{SYMBOL DEAD}}
+
+void getCreatedConjuredSymbolLiveness(std::unique_ptr P) {
+  int *X = P.get();
+  clang_analyzer_warnOnDeadSymbol(X);
+  int Y;
+  if (!P) {
+Y = *P.get(); // expected-warning {{Dereference of null pointer [core.NullDereference]}}
+// expected-warning@-1 {{SYMBOL DEAD}}
+  }
+}
+
+int derefConditionOnUnKnownPtr(int *q) {
+  std::unique_ptr P(q);
+  if (P)
+return *P; // No warning.
+  else
+return *P; // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
Index: clang/test/Analysis/smart-ptr-text-output.cpp
===
--- clang/test/Analysis/smart-ptr-text-output.cpp
+++ clang/test/Analysis/smart-ptr-text-output.cpp
@@ -199,3 +199,108 @@
   PToMove->foo(); // expected-warning {{Dereference of null smart pointer 'PToMove' [alpha.cplusplus.SmartPtr]}}
   // expected-note@-1{{Dereference of null smart pointer 'PToMove'}}
 }
+
+void derefConditionOnNullPtrFalseBranch() {
+  std::unique_ptr P; // expected-note {{Default constructed smart pointer 'P' is null}}
+  if (P) { // expected-note {{Taking false branch}}
+P->foo(); // No warning.
+  } else {
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void derefConditionOnNullPtrTrueBranch() {
+  std::unique_ptr P; // expected-note {{Default constructed smart pointer 'P' is null}}
+  if (!P) { // expected-note {{Taking true branch}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void derefConditionOnValidPtrTrueBranch() {
+  std::unique_ptr P(new A());
+  std::unique_ptr PNull; // expected-note {{Default constructed smart pointer 'PNull' is null}}
+  if (P) { // expected-note {{Taking true branch}}
+PNull->foo(); // expected-warning {{Dereference of null smart pointer 'PNull' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart 

[clang] bc3d4d9 - [analyzer] Add bool operator modeling for unque_ptr

2020-08-31 Thread Nithin Vadukkumchery Rajendrakumar via cfe-commits

Author: Nithin Vadukkumchery Rajendrakumar
Date: 2020-08-31T19:25:33+02:00
New Revision: bc3d4d9ed783a3051125075f1a58ad619d8ea454

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

LOG: [analyzer] Add bool operator modeling for unque_ptr

Summary: Implemented boolean conversion operator for unique_ptr

Reviewers: NoQ, Szelethus, vsavchenko, xazax.hun

Reviewed By: NoQ, xazax.hun

Subscribers: martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D86027

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
clang/test/Analysis/smart-ptr-text-output.cpp
clang/test/Analysis/smart-ptr.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp 
b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
index 391d038c8766..f1ca28ba339d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -15,6 +15,7 @@
 #include "SmartPtr.h"
 
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclarationName.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/LLVM.h"
@@ -35,9 +36,10 @@ using namespace ento;
 
 namespace {
 class SmartPtrModeling
-: public Checker {
+: public Checker {
 
-  bool isAssignOpMethod(const CallEvent ) const;
+  bool isBoolConversionMethod(const CallEvent ) const;
 
 public:
   // Whether the checker should model for null dereferences of smart pointers.
@@ -51,6 +53,9 @@ class SmartPtrModeling
  ArrayRef ExplicitRegions,
  ArrayRef Regions,
  const LocationContext *LCtx, const CallEvent *Call) const;
+  void printState(raw_ostream , ProgramStateRef State, const char *NL,
+  const char *Sep) const;
+  void checkLiveSymbols(ProgramStateRef State, SymbolReaper ) const;
 
 private:
   void handleReset(const CallEvent , CheckerContext ) const;
@@ -62,6 +67,7 @@ class SmartPtrModeling
  const MemRegion *ThisRegion) const;
   bool updateMovedSmartPointers(CheckerContext , const MemRegion *ThisRegion,
 const MemRegion *OtherSmartPtrRegion) const;
+  void handleBoolConversion(const CallEvent , CheckerContext ) const;
 
   using SmartPtrMethodHandlerFn =
   void (SmartPtrModeling::*)(const CallEvent , CheckerContext &) 
const;
@@ -128,7 +134,38 @@ static ProgramStateRef updateSwappedRegion(ProgramStateRef 
State,
   return State;
 }
 
-bool SmartPtrModeling::isAssignOpMethod(const CallEvent ) const {
+// Helper method to get the inner pointer type of specialized smart pointer
+// Returns empty type if not found valid inner pointer type.
+static QualType getInnerPointerType(const CallEvent , CheckerContext ) {
+  const auto *MethodDecl = dyn_cast_or_null(Call.getDecl());
+  if (!MethodDecl || !MethodDecl->getParent())
+return {};
+
+  const auto *RecordDecl = MethodDecl->getParent();
+  if (!RecordDecl || !RecordDecl->isInStdNamespace())
+return {};
+
+  const auto *TSD = dyn_cast(RecordDecl);
+  if (!TSD)
+return {};
+
+  auto TemplateArgs = TSD->getTemplateArgs().asArray();
+  if (TemplateArgs.size() == 0)
+return {};
+  auto InnerValueType = TemplateArgs[0].getAsType();
+  return C.getASTContext().getPointerType(InnerValueType.getCanonicalType());
+}
+
+// Helper method to pretty print region and avoid extra spacing.
+static void checkAndPrettyPrintRegion(llvm::raw_ostream ,
+  const MemRegion *Region) {
+  if (Region->canPrintPretty()) {
+OS << " ";
+Region->printPretty(OS);
+  }
+}
+
+bool SmartPtrModeling::isBoolConversionMethod(const CallEvent ) const {
   // TODO: Update CallDescription to support anonymous calls?
   // TODO: Handle other methods, such as .get() or .release().
   // But once we do, we'd need a visitor to explain null dereferences
@@ -143,21 +180,31 @@ bool SmartPtrModeling::evalCall(const CallEvent ,
   if (!smartptr::isStdSmartPtrCall(Call))
 return false;
 
-  if (isAssignOpMethod(Call)) {
+  if (isBoolConversionMethod(Call)) {
 const MemRegion *ThisR =
 cast()->getCXXThisVal().getAsRegion();
 
-if (!move::isMovedFrom(State, ThisR)) {
-  // TODO: Model this case as well. At least, avoid invalidation of
-  // globals.
-  return false;
+if (ModelSmartPtrDereference) {
+  // The check for the region is moved is duplicated in handleBoolOperation
+  // method.
+  // FIXME: Once we model std::move for smart pointers clean up this and 
use
+  // that modeling.
+  handleBoolConversion(Call, C);
+  return true;
+} else {
+  if (!move::isMovedFrom(State, ThisR)) {
+// TODO: Model this case as well. 

[PATCH] D86700: [SyntaxTree] Ignore leaf implicit `CXXConstructExpr`

2020-08-31 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 288988.
eduucaldas added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86700

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp


Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -548,9 +548,6 @@
   struct S { };
 }
 void test() {
-  // FIXME: Remove the `UnknownExpression` wrapping `s1` and `s2`. This
-  // `UnknownExpression` comes from a leaf `CXXConstructExpr` in the
-  // ClangAST. We need to ignore leaf implicit nodes.
   [[::n::S s1]];
   [[n::S s2]];
 }
@@ -564,8 +561,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s1'
+  `-'s1'
 )txt",
R"txt(
 SimpleDeclaration
@@ -575,8 +571,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s2'
+  `-'s2'
 )txt"}));
 }
 
@@ -608,8 +603,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s1'
+  `-'s1'
 )txt",
R"txt(
 SimpleDeclaration
@@ -623,8 +617,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s2'
+  `-'s2'
 )txt"}));
 }
 
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -1129,6 +1129,12 @@
 return true;
   }
 
+  bool WalkUpFromCXXConstructExpr(CXXConstructExpr *S) {
+if (S->getParenOrBraceRange().isInvalid())
+  return true;
+return RecursiveASTVisitor::WalkUpFromCXXConstructExpr(S);
+  }
+
   bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *S) {
 // To construct a syntax tree of the same shape for calls to built-in and
 // user-defined operators, ignore the `DeclRefExpr` that refers to the


Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -548,9 +548,6 @@
   struct S { };
 }
 void test() {
-  // FIXME: Remove the `UnknownExpression` wrapping `s1` and `s2`. This
-  // `UnknownExpression` comes from a leaf `CXXConstructExpr` in the
-  // ClangAST. We need to ignore leaf implicit nodes.
   [[::n::S s1]];
   [[n::S s2]];
 }
@@ -564,8 +561,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s1'
+  `-'s1'
 )txt",
R"txt(
 SimpleDeclaration
@@ -575,8 +571,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s2'
+  `-'s2'
 )txt"}));
 }
 
@@ -608,8 +603,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s1'
+  `-'s1'
 )txt",
R"txt(
 SimpleDeclaration
@@ -623,8 +617,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s2'
+  `-'s2'
 )txt"}));
 }
 
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -1129,6 +1129,12 @@
 return true;
   }
 
+  bool WalkUpFromCXXConstructExpr(CXXConstructExpr *S) {
+if (S->getParenOrBraceRange().isInvalid())
+  return true;
+return RecursiveASTVisitor::WalkUpFromCXXConstructExpr(S);
+  }
+
   bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *S) {
 // To construct a syntax tree of the same shape for calls to built-in and
 // user-defined operators, ignore the `DeclRefExpr` that refers to the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86699: [SyntaxTree] Ignore implicit non-leaf `CXXConstructExpr`

2020-08-31 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a reviewer: gribozavr2.
eduucaldas added inline comments.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:48-58
+static Expr *IgnoreImplicitCXXConstructExpr(Expr *E) {
+  if (auto *C = dyn_cast(E)) {
+auto NumArgs = C->getNumArgs();
+if (NumArgs == 1 || (NumArgs > 1 && isa(C->getArg(1 
{
+  auto *A = C->getArg(0);
+  if (A->getSourceRange() == E->getSourceRange())
+return A;

Should this go into `IgnoreExpr` as well?

If yes, should we unify this with the lambda inside 
`IgnoreUnlessSpelledInSource`, thus removing the lambda and using this free 
function instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86699

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


[PATCH] D86699: [SyntaxTree] Ignore implicit non-leaf `CXXConstructExpr`

2020-08-31 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 288987.
eduucaldas added a comment.

nits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86699

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp


Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -1745,19 +1745,15 @@
 struct X {
   friend X operator+(X, const X&);
 };
-// FIXME: Remove additional `UnknownExpression` wrapping `x`. For that, ignore
-// implicit copy constructor called on `x`. This should've been ignored 
already,
-// as we `IgnoreImplicit` when traversing an `Stmt`.
 void test(X x, X y) {
   [[x + y]];
 }
 )cpp",
   {R"txt(
 BinaryOperatorExpression Expression
-|-UnknownExpression LeftHandSide
-| `-IdExpression
-|   `-UnqualifiedId UnqualifiedId
-| `-'x'
+|-IdExpression LeftHandSide
+| `-UnqualifiedId UnqualifiedId
+|   `-'x'
 |-'+' OperatorToken
 `-IdExpression RightHandSide
   `-UnqualifiedId UnqualifiedId
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -13,6 +13,7 @@
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/IgnoreExpr.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TypeLoc.h"
@@ -44,8 +45,25 @@
 
 using namespace clang;
 
+static Expr *IgnoreImplicitCXXConstructExpr(Expr *E) {
+  if (auto *C = dyn_cast(E)) {
+auto NumArgs = C->getNumArgs();
+if (NumArgs == 1 || (NumArgs > 1 && isa(C->getArg(1 
{
+  auto *A = C->getArg(0);
+  if (A->getSourceRange() == E->getSourceRange())
+return A;
+}
+  }
+  return E;
+}
+
+static Expr *IgnoreImplicit(Expr *E) {
+  return IgnoreExprNodes(E, IgnoreImplicitSingleStep,
+ IgnoreImplicitCXXConstructExpr);
+}
+
 LLVM_ATTRIBUTE_UNUSED
-static bool isImplicitExpr(Expr *E) { return E->IgnoreImplicit() != E; }
+static bool isImplicitExpr(Expr *E) { return IgnoreImplicit(E) != E; }
 
 namespace {
 /// Get start location of the Declarator from the TypeLoc.
@@ -740,7 +758,7 @@
   for (auto *D : DS->decls())
 Builder.noticeDeclWithoutSemicolon(D);
 } else if (auto *E = dyn_cast_or_null(S)) {
-  return RecursiveASTVisitor::TraverseStmt(E->IgnoreImplicit());
+  return RecursiveASTVisitor::TraverseStmt(IgnoreImplicit(E));
 }
 return RecursiveASTVisitor::TraverseStmt(S);
   }
@@ -1579,7 +1597,7 @@
 void syntax::TreeBuilder::markExprChild(Expr *Child, NodeRole Role) {
   if (!Child)
 return;
-  Child = Child->IgnoreImplicit();
+  Child = IgnoreImplicit(Child);
 
   syntax::Tree *ChildNode = Mapping.find(Child);
   assert(ChildNode != nullptr);


Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -1745,19 +1745,15 @@
 struct X {
   friend X operator+(X, const X&);
 };
-// FIXME: Remove additional `UnknownExpression` wrapping `x`. For that, ignore
-// implicit copy constructor called on `x`. This should've been ignored already,
-// as we `IgnoreImplicit` when traversing an `Stmt`.
 void test(X x, X y) {
   [[x + y]];
 }
 )cpp",
   {R"txt(
 BinaryOperatorExpression Expression
-|-UnknownExpression LeftHandSide
-| `-IdExpression
-|   `-UnqualifiedId UnqualifiedId
-| `-'x'
+|-IdExpression LeftHandSide
+| `-UnqualifiedId UnqualifiedId
+|   `-'x'
 |-'+' OperatorToken
 `-IdExpression RightHandSide
   `-UnqualifiedId UnqualifiedId
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -13,6 +13,7 @@
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/IgnoreExpr.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TypeLoc.h"
@@ -44,8 +45,25 @@
 
 using namespace clang;
 
+static Expr *IgnoreImplicitCXXConstructExpr(Expr *E) {
+  if (auto *C = dyn_cast(E)) {
+auto NumArgs = C->getNumArgs();
+if (NumArgs == 1 || (NumArgs > 1 && isa(C->getArg(1 {
+  auto *A = C->getArg(0);
+  if (A->getSourceRange() == E->getSourceRange())
+return A;
+}
+  }
+  return E;
+}
+
+static Expr *IgnoreImplicit(Expr *E) {
+  return IgnoreExprNodes(E, IgnoreImplicitSingleStep,
+ IgnoreImplicitCXXConstructExpr);
+}
+
 LLVM_ATTRIBUTE_UNUSED
-static bool isImplicitExpr(Expr *E) { 

[PATCH] D82118: [clang][module] Improve incomplete-umbrella warning

2020-08-31 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.



> Yes the wrapper is definitely problematic. I'm checking how the diagnostic 
> itself is handled correctly and start from there when I have time. For now 
> would it be better to separate this into multiple patches and get the 
> diagnostic improvement in first?

Yep, that would be better!




Comment at: 
clang/test/Modules/Inputs/incomplete-umbrella/normal-module/Umbrella.h:1-3
+// Umbrella.h
+// CHECK: #import "A1.h"
+// CHECK: #import "A2.h"

zixuw wrote:
> > What about `CHECK`s for the introduced fix-its? I don't see a `#include` or 
> > `#import` being matched in the tests.
> 
> Is this the check you're looking for? It is checked in 
> `incomplete-umbrella-fixit.m`:
> ```
> RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/module.modulemap 
> -fmodules-cache-path=%t -Wno-everything -Wincomplete-umbrella -fixit %s && 
> FileCheck %t/Umbrella.h --input-file %t/Umbrella.h --match-full-lines
> ```
Oh, right. my bad! Can we get a test for `#include` too? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82118

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


[PATCH] D86699: [SyntaxTree] Ignore implicit non-leaf `CXXConstructExpr`

2020-08-31 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 288984.
eduucaldas added a comment.

Use `IgnoreExpr.h` infrastructure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86699

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp


Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -1745,19 +1745,15 @@
 struct X {
   friend X operator+(X, const X&);
 };
-// FIXME: Remove additional `UnknownExpression` wrapping `x`. For that, ignore
-// implicit copy constructor called on `x`. This should've been ignored 
already,
-// as we `IgnoreImplicit` when traversing an `Stmt`.
 void test(X x, X y) {
   [[x + y]];
 }
 )cpp",
   {R"txt(
 BinaryOperatorExpression Expression
-|-UnknownExpression LeftHandSide
-| `-IdExpression
-|   `-UnqualifiedId UnqualifiedId
-| `-'x'
+|-IdExpression LeftHandSide
+| `-UnqualifiedId UnqualifiedId
+|   `-'x'
 |-'+' OperatorToken
 `-IdExpression RightHandSide
   `-UnqualifiedId UnqualifiedId
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -13,6 +13,7 @@
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/IgnoreExpr.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TypeLoc.h"
@@ -44,8 +45,25 @@
 
 using namespace clang;
 
+static Expr *ignoreImplicitCXXConstructExpr(Expr *E) {
+  if (auto *C = dyn_cast(E)) {
+auto NumArgs = C->getNumArgs();
+if (NumArgs == 1 || (NumArgs > 1 && isa(C->getArg(1 
{
+  auto *A = C->getArg(0);
+  if (A->getSourceRange() == E->getSourceRange())
+return A;
+}
+  }
+  return E;
+}
+
+static Expr *ignoreImplicit(Expr *E) {
+  return IgnoreExprNodes(E, IgnoreImplicitSingleStep,
+ ignoreImplicitCXXConstructExpr);
+}
+
 LLVM_ATTRIBUTE_UNUSED
-static bool isImplicitExpr(Expr *E) { return E->IgnoreImplicit() != E; }
+static bool isImplicitExpr(Expr *E) { return ignoreImplicit(E) != E; }
 
 namespace {
 /// Get start location of the Declarator from the TypeLoc.
@@ -740,7 +758,7 @@
   for (auto *D : DS->decls())
 Builder.noticeDeclWithoutSemicolon(D);
 } else if (auto *E = dyn_cast_or_null(S)) {
-  return RecursiveASTVisitor::TraverseStmt(E->IgnoreImplicit());
+  return RecursiveASTVisitor::TraverseStmt(ignoreImplicit(E));
 }
 return RecursiveASTVisitor::TraverseStmt(S);
   }
@@ -1579,7 +1597,7 @@
 void syntax::TreeBuilder::markExprChild(Expr *Child, NodeRole Role) {
   if (!Child)
 return;
-  Child = Child->IgnoreImplicit();
+  Child = ignoreImplicit(Child);
 
   syntax::Tree *ChildNode = Mapping.find(Child);
   assert(ChildNode != nullptr);


Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -1745,19 +1745,15 @@
 struct X {
   friend X operator+(X, const X&);
 };
-// FIXME: Remove additional `UnknownExpression` wrapping `x`. For that, ignore
-// implicit copy constructor called on `x`. This should've been ignored already,
-// as we `IgnoreImplicit` when traversing an `Stmt`.
 void test(X x, X y) {
   [[x + y]];
 }
 )cpp",
   {R"txt(
 BinaryOperatorExpression Expression
-|-UnknownExpression LeftHandSide
-| `-IdExpression
-|   `-UnqualifiedId UnqualifiedId
-| `-'x'
+|-IdExpression LeftHandSide
+| `-UnqualifiedId UnqualifiedId
+|   `-'x'
 |-'+' OperatorToken
 `-IdExpression RightHandSide
   `-UnqualifiedId UnqualifiedId
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -13,6 +13,7 @@
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/IgnoreExpr.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TypeLoc.h"
@@ -44,8 +45,25 @@
 
 using namespace clang;
 
+static Expr *ignoreImplicitCXXConstructExpr(Expr *E) {
+  if (auto *C = dyn_cast(E)) {
+auto NumArgs = C->getNumArgs();
+if (NumArgs == 1 || (NumArgs > 1 && isa(C->getArg(1 {
+  auto *A = C->getArg(0);
+  if (A->getSourceRange() == E->getSourceRange())
+return A;
+}
+  }
+  return E;
+}
+
+static Expr *ignoreImplicit(Expr *E) {
+  return IgnoreExprNodes(E, IgnoreImplicitSingleStep,
+ ignoreImplicitCXXConstructExpr);
+}
+
 LLVM_ATTRIBUTE_UNUSED
-static 

[PATCH] D85424: [Analyzer] Crash fix for alpha.cplusplus.IteratorRange

2020-08-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D85424#2247598 , @gamesh411 wrote:

> `CReduce` did not manage to produce any meaningful result after a week worth 
> of runtime (more than ~2000 lines of code still remaining after reduction). 
> We could track this down by tracing the ExprEngine code that assigns the 
> Undefined SVal but that seems a huge effort as well. That could be done by 
> debugging the SVal-assigning statements, and setting conditional breakpoints 
> (ie. only break when the value is Undefined). When a breakpoint is hit, we 
> could dump the statement that triggered it and try to reason about the 
> conditions at that point. I also recommend using the `rr` tool as it allows 
> you to use fixed pointer values while debugging.

I'm volunteering. I did some debugging lately, I would give a shot catching 
this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85424

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


[PATCH] D86820: [X86] Add a /tune: option for clang-cl

2020-08-31 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D86820#2247336 , @hans wrote:

> Would it be enough for users to specify /clang:-mtune instead? How does icc 
> spell its option?

I didn't know you could spell it as /clang:-mtune. ICC has /tune: according 
to this documentation 
https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/code-generation-options/mtune-tune.html


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

https://reviews.llvm.org/D86820

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


[PATCH] D86778: Extract infrastructure to ignore intermediate expressions into `clang/AST/IgnoreExpr.h`

2020-08-31 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 288978.
eduucaldas marked an inline comment as done.
eduucaldas added a comment.

Answer comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86778

Files:
  clang/include/clang/AST/IgnoreExpr.h
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Expr.cpp
  clang/lib/AST/IgnoreExpr.cpp

Index: clang/lib/AST/IgnoreExpr.cpp
===
--- /dev/null
+++ clang/lib/AST/IgnoreExpr.cpp
@@ -0,0 +1,129 @@
+//===--- IgnoreExpr.cpp - Ignore intermediate Expressions -===//
+//
+// 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
+//
+//===--===//
+//
+// This file implements common functions to ignore intermediate expression nodes
+//
+//===--===//
+
+#include "clang/AST/IgnoreExpr.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+
+using namespace clang;
+
+Expr *clang::IgnoreImplicitCastsSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast(E))
+return ICE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
+  return E;
+}
+
+Expr *clang::IgnoreImplicitCastsExtraSingleStep(Expr *E) {
+  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
+  // addition to what IgnoreImpCasts() skips to account for the current
+  // behaviour of IgnoreParenImpCasts().
+  Expr *SubE = IgnoreImplicitCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
+
+  return E;
+}
+
+Expr *clang::IgnoreCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+return CE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
+
+  return E;
+}
+
+Expr *clang::IgnoreLValueCastsSingleStep(Expr *E) {
+  // Skip what IgnoreCastsSingleStep skips, except that only
+  // lvalue-to-rvalue casts are skipped.
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() != CK_LValueToRValue)
+  return E;
+
+  return IgnoreCastsSingleStep(E);
+}
+
+Expr *clang::IgnoreBaseCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() == CK_DerivedToBase ||
+CE->getCastKind() == CK_UncheckedDerivedToBase ||
+CE->getCastKind() == CK_NoOp)
+  return CE->getSubExpr();
+
+  return E;
+}
+
+Expr *clang::IgnoreImplicitSingleStep(Expr *E) {
+  Expr *SubE = IgnoreImplicitCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *BTE = dyn_cast(E))
+return BTE->getSubExpr();
+
+  return E;
+}
+
+Expr *clang::IgnoreImplicitAsWrittenSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast(E))
+return ICE->getSubExprAsWritten();
+
+  return IgnoreImplicitSingleStep(E);
+}
+
+Expr *clang::IgnoreParensOnlySingleStep(Expr *E) {
+  if (auto *PE = dyn_cast(E))
+return PE->getSubExpr();
+  return E;
+}
+
+Expr *clang::IgnoreParensSingleStep(Expr *E) {
+  if (auto *PE = dyn_cast(E))
+return PE->getSubExpr();
+
+  if (auto *UO = dyn_cast(E)) {
+if (UO->getOpcode() == UO_Extension)
+  return UO->getSubExpr();
+  }
+
+  else if (auto *GSE = dyn_cast(E)) {
+if (!GSE->isResultDependent())
+  return GSE->getResultExpr();
+  }
+
+  else if (auto *CE = dyn_cast(E)) {
+if (!CE->isConditionDependent())
+  return CE->getChosenSubExpr();
+  }
+
+  return E;
+}
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/DependenceFlags.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/IgnoreExpr.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtVisitor.h"
@@ -2779,118 +2780,6 @@
   return QualType();
 }
 
-static Expr *IgnoreImpCastsSingleStep(Expr *E) {
-  if (auto *ICE = dyn_cast(E))
-return ICE->getSubExpr();
-
-  if (auto *FE = dyn_cast(E))
-return FE->getSubExpr();
-
-  return E;
-}
-
-static Expr *IgnoreImpCastsExtraSingleStep(Expr *E) {
-  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
-  // addition to what IgnoreImpCasts() skips to account for the current
-  // behaviour of IgnoreParenImpCasts().
-  Expr *SubE = IgnoreImpCastsSingleStep(E);
-  if (SubE != E)
-return SubE;
-
-  if (auto *MTE = dyn_cast(E))
-return 

[PATCH] D86027: [analyzer] Add bool operator modeling for unque_ptr

2020-08-31 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LG! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86027

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


[PATCH] D86027: [analyzer] Add bool operator modeling for unque_ptr

2020-08-31 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar marked an inline comment as done.
vrnithinkumar added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:556
+const LocationContext *LC = C.getLocationContext();
+InnerPointerVal = C.getSValBuilder().conjureSymbolVal(
+CallExpr, LC, InnerPointerType, C.blockCount());

xazax.hun wrote:
> Don't we want to actually add InnerPointerVal to TrackedRegionMap in this 
> case?
> 
> I might be wrong but I cannot find where do we actually record the fact that 
> this freshly conjured symbol belongs to the unique_ptr we are modeling.
Thanks for catching that. 
We have to update the `TrackedRegionMap` to track the created conjureSymbolVal  
`InnerPointerVal`.
Updated to add it to the `TrackedRegionMap`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86027

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


[PATCH] D86027: [analyzer] Add bool operator modeling for unque_ptr

2020-08-31 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar updated this revision to Diff 288974.
vrnithinkumar added a comment.

- Fixing minor spacing issue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86027

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/smart-ptr-text-output.cpp
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -8,12 +8,13 @@
 void clang_analyzer_warnIfReached();
 void clang_analyzer_numTimesReached();
 void clang_analyzer_eval(bool);
+void clang_analyzer_warnOnDeadSymbol(int *);
 
 void derefAfterMove(std::unique_ptr P) {
   std::unique_ptr Q = std::move(P);
   if (Q)
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
-  *Q.get() = 1; // no-warning
+  *Q.get() = 1; // expected-warning {{Dereference of null pointer [core.NullDereference]}}
   if (P)
 clang_analyzer_warnIfReached(); // no-warning
   // TODO: Report a null dereference (instead).
@@ -375,3 +376,77 @@
   std::unique_ptr P(functionReturnsRValueRef());
   P->foo();  // No warning.
 }
+
+void derefConditionOnNullPtr() {
+  std::unique_ptr P;
+  if (P)
+P->foo(); // No warning.
+  else
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefConditionOnNotNullPtr() {
+  std::unique_ptr P;
+  if (!P)
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefConditionOnValidPtr() {
+  std::unique_ptr P(new A());
+  std::unique_ptr PNull;
+  if (P)
+PNull->foo(); // expected-warning {{Dereference of null smart pointer 'PNull' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefConditionOnNotValidPtr() {
+  std::unique_ptr P(new A());
+  std::unique_ptr PNull;
+  if (!P)
+PNull->foo(); // No warning.
+}
+
+void derefConditionOnUnKnownPtr(std::unique_ptr P) {
+  if (P)
+P->foo(); // No warning.
+  else
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefOnValidPtrAfterReset(std::unique_ptr P) {
+  P.reset(new A());
+  if (!P)
+P->foo(); // No warning.
+  else
+P->foo(); // No warning.
+}
+
+void innerPointerSymbolLiveness() {
+  std::unique_ptr P(new int());
+  clang_analyzer_warnOnDeadSymbol(P.get());
+  int *RP = P.release();
+} // expected-warning{{SYMBOL DEAD}}
+
+void boolOpCreatedConjuredSymbolLiveness(std::unique_ptr P) {
+  if (P) {
+int *X = P.get();
+clang_analyzer_warnOnDeadSymbol(X);
+  }
+} // expected-warning{{SYMBOL DEAD}}
+
+void getCreatedConjuredSymbolLiveness(std::unique_ptr P) {
+  int *X = P.get();
+  clang_analyzer_warnOnDeadSymbol(X);
+  int Y;
+  if (!P) {
+Y = *P.get(); // expected-warning {{Dereference of null pointer [core.NullDereference]}}
+// expected-warning@-1 {{SYMBOL DEAD}}
+  }
+}
+
+int derefConditionOnUnKnownPtr(int *q) {
+  std::unique_ptr P(q);
+  if (P)
+return *P; // No warning.
+  else
+return *P; // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
Index: clang/test/Analysis/smart-ptr-text-output.cpp
===
--- clang/test/Analysis/smart-ptr-text-output.cpp
+++ clang/test/Analysis/smart-ptr-text-output.cpp
@@ -199,3 +199,108 @@
   PToMove->foo(); // expected-warning {{Dereference of null smart pointer 'PToMove' [alpha.cplusplus.SmartPtr]}}
   // expected-note@-1{{Dereference of null smart pointer 'PToMove'}}
 }
+
+void derefConditionOnNullPtrFalseBranch() {
+  std::unique_ptr P; // expected-note {{Default constructed smart pointer 'P' is null}}
+  if (P) { // expected-note {{Taking false branch}}
+P->foo(); // No warning.
+  } else {
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void derefConditionOnNullPtrTrueBranch() {
+  std::unique_ptr P; // expected-note {{Default constructed smart pointer 'P' is null}}
+  if (!P) { // expected-note {{Taking true branch}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void derefConditionOnValidPtrTrueBranch() {
+  std::unique_ptr P(new A());
+  std::unique_ptr PNull; // expected-note {{Default constructed smart pointer 'PNull' is null}}
+  if (P) { // expected-note {{Taking true branch}}
+PNull->foo(); // expected-warning {{Dereference of null smart pointer 'PNull' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'PNull'}}
+  } else {
+PNull->foo(); // No warning
+  }
+}
+
+void derefConditionOnValidPtrFalseBranch() {
+  

[PATCH] D86027: [analyzer] Add bool operator modeling for unque_ptr

2020-08-31 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar updated this revision to Diff 288972.
vrnithinkumar added a comment.

- Addressing review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86027

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/smart-ptr-text-output.cpp
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -8,12 +8,13 @@
 void clang_analyzer_warnIfReached();
 void clang_analyzer_numTimesReached();
 void clang_analyzer_eval(bool);
+void clang_analyzer_warnOnDeadSymbol(int *);
 
 void derefAfterMove(std::unique_ptr P) {
   std::unique_ptr Q = std::move(P);
   if (Q)
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
-  *Q.get() = 1; // no-warning
+  *Q.get() = 1; // expected-warning {{Dereference of null pointer [core.NullDereference]}}
   if (P)
 clang_analyzer_warnIfReached(); // no-warning
   // TODO: Report a null dereference (instead).
@@ -375,3 +376,77 @@
   std::unique_ptr P(functionReturnsRValueRef());
   P->foo();  // No warning.
 }
+
+void derefConditionOnNullPtr() {
+  std::unique_ptr P;
+  if (P)
+P->foo(); // No warning.
+  else
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefConditionOnNotNullPtr() {
+  std::unique_ptr P;
+  if (!P)
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefConditionOnValidPtr() {
+  std::unique_ptr P(new A());
+  std::unique_ptr PNull;
+  if (P)
+PNull->foo(); // expected-warning {{Dereference of null smart pointer 'PNull' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefConditionOnNotValidPtr() {
+  std::unique_ptr P(new A());
+  std::unique_ptr PNull;
+  if (!P)
+PNull->foo(); // No warning.
+}
+
+void derefConditionOnUnKnownPtr(std::unique_ptr P) {
+  if (P)
+P->foo(); // No warning.
+  else
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefOnValidPtrAfterReset(std::unique_ptr P) {
+  P.reset(new A());
+  if (!P)
+P->foo(); // No warning.
+  else
+P->foo(); // No warning.
+}
+
+void innerPointerSymbolLiveness() {
+  std::unique_ptr P(new int());
+  clang_analyzer_warnOnDeadSymbol(P.get());
+  int *RP = P.release();
+} // expected-warning{{SYMBOL DEAD}}
+
+void boolOpCreatedConjuredSymbolLiveness(std::unique_ptr P) {
+  if (P) {
+int *X = P.get();
+clang_analyzer_warnOnDeadSymbol(X);
+  }
+} // expected-warning{{SYMBOL DEAD}}
+
+void getCreatedConjuredSymbolLiveness(std::unique_ptr P) {
+  int *X = P.get();
+  clang_analyzer_warnOnDeadSymbol(X);
+  int Y;
+  if (!P) {
+Y = *P.get(); // expected-warning {{Dereference of null pointer [core.NullDereference]}}
+// expected-warning@-1 {{SYMBOL DEAD}}
+  }
+}
+
+int derefConditionOnUnKnownPtr(int *q) {
+  std::unique_ptr P(q);
+  if (P)
+return *P; // No warning.
+  else
+return *P; // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
Index: clang/test/Analysis/smart-ptr-text-output.cpp
===
--- clang/test/Analysis/smart-ptr-text-output.cpp
+++ clang/test/Analysis/smart-ptr-text-output.cpp
@@ -170,7 +170,6 @@
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
   // expected-note@-1 {{Dereference of null smart pointer 'P'}}
 }
-
 void derefMoveConstructedWithNullPtr() {
   std::unique_ptr PToMove; // expected-note {{Default constructed smart pointer 'PToMove' is null}}
   std::unique_ptr P(std::move(PToMove)); // expected-note {{A null pointer value is moved to 'P'}}
@@ -199,3 +198,109 @@
   PToMove->foo(); // expected-warning {{Dereference of null smart pointer 'PToMove' [alpha.cplusplus.SmartPtr]}}
   // expected-note@-1{{Dereference of null smart pointer 'PToMove'}}
 }
+
+void derefConditionOnNullPtrFalseBranch() {
+  std::unique_ptr P; // expected-note {{Default constructed smart pointer 'P' is null}}
+  if (P) { // expected-note {{Taking false branch}}
+P->foo(); // No warning.
+  } else {
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void derefConditionOnNullPtrTrueBranch() {
+  std::unique_ptr P; // expected-note {{Default constructed smart pointer 'P' is null}}
+  if (!P) { // expected-note {{Taking true branch}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void derefConditionOnValidPtrTrueBranch() {
+  std::unique_ptr P(new A());
+  

[PATCH] D86881: Make -fvisibility-inlines-hidden apply to static local variables in inline functions on Darwin

2020-08-31 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added a reviewer: arphaman.
Herald added subscribers: dang, ributzka, dexonsmith, jkorous.
erik.pilkington requested review of this revision.

This effectively disables https://reviews.llvm.org/D50968 on Darwin, and 
provides a command line flag to opt into/out of this behaviour. This change is 
needed to compile certain Apple headers correctly.

rdar://47688592


https://reviews.llvm.org/D86881

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Decl.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/visibility-inlines-hidden-static-local-var.cpp
  clang/test/Driver/darwin-objc-options.m

Index: clang/test/Driver/darwin-objc-options.m
===
--- clang/test/Driver/darwin-objc-options.m
+++ clang/test/Driver/darwin-objc-options.m
@@ -46,3 +46,12 @@
 // RUN: %clang -target x86_64-linux-gnu -### %s 2>&1 | FileCheck --check-prefix=OTHER_COMPATIBILITY %s
 // DARWIN_COMPATIBILITY: -fcompatibility-qualified-id-block-type-checking
 // OTHER_COMPATIBILITY-NOT: -fcompatibility-qualified-id-block-type-checking
+
+// Add -fvisibility-inlines-hidden-static-local-var on Darwin.
+// RUN: %clang -target x86_64-apple-darwin10 -### %s 2>&1 | FileCheck --check-prefix=DARWIN_INLINES_HIDDEN %s
+// RUN: %clang -target x86_64-apple-darwin10 -fno-visibility-inlines-hidden-static-local-var -### %s 2>&1 | FileCheck --check-prefix=DARWIN_INLINES_HIDDEN_EXPLICIT_NO %s
+// RUN: %clang -target x86_64-linux-gnu -### %s 2>&1 | FileCheck --check-prefix=NO_DARWIN_INLINES_HIDDEN %s
+// DARWIN_INLINES_HIDDEN: -fvisibility-inlines-hidden-static-local-var
+// DARWIN_INLINES_HIDDEN_EXPLICIT_NO-NOT: -fvisibility-inlines-hidden-static-local-var
+// DARWIN_INLINES_HIDDEN_EXPLICIT_NO: -fno-visibility-inlines-hidden-static-local-var
+// NO_DARWIN_INLINES_HIDDEN-NOT: -fvisibility-inlines-hidden-static-local-var
Index: clang/test/CodeGenCXX/visibility-inlines-hidden-static-local-var.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/visibility-inlines-hidden-static-local-var.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fvisibility-inlines-hidden -fvisibility-inlines-hidden-static-local-var %s -emit-llvm -o - | FileCheck %s
+
+#define used __attribute__((used))
+
+used inline void f1() {
+  // CHECK: @_ZZ2f1vE6f1_var = linkonce_odr hidden global i32 0
+  static int f1_var = 0;
+}
+
+__attribute__((visibility("default")))
+used inline void f2() {
+  // CHECK: @_ZZ2f2vE6f2_var = linkonce_odr global i32 0
+  static int f2_var = 0;
+}
+
+struct S {
+  used void f3() {
+// CHECK: @_ZZN1S2f3EvE6f3_var = linkonce_odr hidden global i32 0
+static int f3_var = 0;
+  }
+
+  void f6();
+  void f7();
+};
+
+used void f4() {
+  // CHECK: @_ZZ2f4vE6f4_var = internal global i32 0
+  static int f4_var = 0;
+}
+
+__attribute__((visibility("default")))
+used void f5() {
+  // CHECK: @_ZZ2f5vE6f5_var = internal global i32 0
+  static int f5_var = 0;
+}
+
+used void S::f6() {
+  // CHECK: @_ZZN1S2f6EvE6f6_var = internal global i32 0
+  static int f6_var = 0;
+}
+
+used inline void S::f7() {
+  // CHECK: @_ZZN1S2f7EvE6f7_var = linkonce_odr hidden global i32 0
+  static int f7_var = 0;
+}
+
+
+struct __attribute__((visibility("default"))) S2 {
+  used void f8() {
+// CHECK: @_ZZN2S22f8EvE6f8_var = linkonce_odr hidden global i32 0
+static int f8_var = 0;
+  }
+};
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2766,6 +2766,9 @@
   if (Args.hasArg(OPT_fvisibility_inlines_hidden))
 Opts.InlineVisibilityHidden = 1;
 
+  if (Args.hasArg(OPT_fvisibility_inlines_hidden_static_local_var))
+Opts.VisibilityInlinesHiddenStaticLocalVar = 1;
+
   if (Args.hasArg(OPT_fvisibility_global_new_delete_hidden))
 Opts.GlobalAllocationFunctionVisibilityHidden = 1;
 
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2408,6 +2408,13 @@
   // Enable compatibility mode for NSItemProviderCompletionHandler in
   // Foundation/NSItemProvider.h.
   CC1Args.push_back("-fcompatibility-qualified-id-block-type-checking");
+
+  // Give static local variables in inline functions hidden visibility when
+  // -fvisibility-inlines-hidden is enabled.
+  if (!DriverArgs.getLastArgNoClaim(
+  options::OPT_fvisibility_inlines_hidden_static_local_var,
+  options::OPT_fno_visibility_inlines_hidden_static_local_var))
+CC1Args.push_back("-fvisibility-inlines-hidden-static-local-var");
 }
 
 DerivedArgList 

[PATCH] D85424: [Analyzer] Crash fix for alpha.cplusplus.IteratorRange

2020-08-31 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

`CReduce` did not manage to produce any meaningful result after a week worth of 
runtime (more than ~2000 lines of code still remaining after reduction). We 
could track this down by tracing the ExprEngine code that assigns the Undefined 
SVal but that seems a huge effort as well. That could be done by debugging the 
SVal-assigning statements, and setting conditional breakpoints (ie. only break 
when the value is Undefined). When a breakpoint is hit, we could dump the 
statement that triggered it and try to reason about the conditions at that 
point. I also recommend using the `rr` tool as it allows you to use fixed 
pointer values while debugging.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85424

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


[PATCH] D86858: [OpenMP] Fix infinite loop in Sema::isOpenMPGlobalCapturedDecl()

2020-08-31 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86858

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


[PATCH] D86778: Extract infrastructure to ignore intermediate expressions into `clang/AST/IgnoreExpr.h`

2020-08-31 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 288965.
eduucaldas added a comment.

Fix lint problems


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86778

Files:
  clang/include/clang/AST/IgnoreExpr.h
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Expr.cpp
  clang/lib/AST/IgnoreExpr.cpp

Index: clang/lib/AST/IgnoreExpr.cpp
===
--- /dev/null
+++ clang/lib/AST/IgnoreExpr.cpp
@@ -0,0 +1,129 @@
+//===--- IgnoreExpr.cpp - Ignore intermediate Expressions -===//
+//
+// 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
+//
+//===--===//
+//
+// This file implements common functions to ignore intermediate expression nodes
+//
+//===--===//
+
+#include "clang/AST/IgnoreExpr.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+
+using namespace clang;
+
+Expr *clang::IgnoreImpCastsSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast(E))
+return ICE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
+  return E;
+}
+
+Expr *clang::IgnoreImpCastsExtraSingleStep(Expr *E) {
+  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
+  // addition to what IgnoreImpCasts() skips to account for the current
+  // behaviour of IgnoreParenImpCasts().
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
+
+  return E;
+}
+
+Expr *clang::IgnoreCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+return CE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
+
+  return E;
+}
+
+Expr *clang::IgnoreLValueCastsSingleStep(Expr *E) {
+  // Skip what IgnoreCastsSingleStep skips, except that only
+  // lvalue-to-rvalue casts are skipped.
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() != CK_LValueToRValue)
+  return E;
+
+  return IgnoreCastsSingleStep(E);
+}
+
+Expr *clang::IgnoreBaseCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() == CK_DerivedToBase ||
+CE->getCastKind() == CK_UncheckedDerivedToBase ||
+CE->getCastKind() == CK_NoOp)
+  return CE->getSubExpr();
+
+  return E;
+}
+
+Expr *clang::IgnoreImplicitSingleStep(Expr *E) {
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *BTE = dyn_cast(E))
+return BTE->getSubExpr();
+
+  return E;
+}
+
+Expr *clang::IgnoreImplicitAsWrittenSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast(E))
+return ICE->getSubExprAsWritten();
+
+  return IgnoreImplicitSingleStep(E);
+}
+
+Expr *clang::IgnoreParensOnlySingleStep(Expr *E) {
+  if (auto *PE = dyn_cast(E))
+return PE->getSubExpr();
+  return E;
+}
+
+Expr *clang::IgnoreParensSingleStep(Expr *E) {
+  if (auto *PE = dyn_cast(E))
+return PE->getSubExpr();
+
+  if (auto *UO = dyn_cast(E)) {
+if (UO->getOpcode() == UO_Extension)
+  return UO->getSubExpr();
+  }
+
+  else if (auto *GSE = dyn_cast(E)) {
+if (!GSE->isResultDependent())
+  return GSE->getResultExpr();
+  }
+
+  else if (auto *CE = dyn_cast(E)) {
+if (!CE->isConditionDependent())
+  return CE->getChosenSubExpr();
+  }
+
+  return E;
+}
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/DependenceFlags.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/IgnoreExpr.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtVisitor.h"
@@ -2779,118 +2780,6 @@
   return QualType();
 }
 
-static Expr *IgnoreImpCastsSingleStep(Expr *E) {
-  if (auto *ICE = dyn_cast(E))
-return ICE->getSubExpr();
-
-  if (auto *FE = dyn_cast(E))
-return FE->getSubExpr();
-
-  return E;
-}
-
-static Expr *IgnoreImpCastsExtraSingleStep(Expr *E) {
-  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
-  // addition to what IgnoreImpCasts() skips to account for the current
-  // behaviour of IgnoreParenImpCasts().
-  Expr *SubE = IgnoreImpCastsSingleStep(E);
-  if (SubE != E)
-return SubE;
-
-  if (auto *MTE = dyn_cast(E))
-return MTE->getSubExpr();
-
-  if (auto *NTTP = dyn_cast(E))
-return 

[PATCH] D86778: Extract infrastructure to ignore intermediate expressions into `clang/AST/IgnoreExpr.h`

2020-08-31 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/AST/IgnoreExpr.h:15
+namespace clang {
+namespace {
+/// Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *,

Each occurrence of unnamed namespace creates separate entities, so we would 
have ODR violations in `IgnoreExprNodes`.



Comment at: clang/include/clang/AST/IgnoreExpr.h:37
+
+Expr *IgnoreImpCastsSingleStep(Expr *E);
+

Expand "Imp" to "Implicit"? (Here and one more below.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86778

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


[PATCH] D86880: [Ignore Expressions][NFC] Refactor to better use `IgnoreExpr.h` and nits

2020-08-31 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
eduucaldas added a reviewer: gribozavr2.
Herald added subscribers: cfe-commits, martong.
Herald added a project: clang.
eduucaldas requested review of this revision.

This change groups

- Rename: `ignoreParenBaseCasts` -> `IgnoreParenBaseCasts` for uniformity
- Rename: `IgnoreConversionOperator` -> `IgnoreConversionOperatorSingleStep` 
for uniformity
- Inline `IgnoreNoopCastsSingleStep` into a lambda inside `IgnoreNoopCasts`
- Refactor `IgnoreUnlessSpelledInSource` to make adequate use of 
`IgnoreExprNodes`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86880

Files:
  clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
  clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
  clang/include/clang/AST/Expr.h
  clang/lib/AST/Expr.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp

Index: clang/lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -687,7 +687,7 @@
 // base class decl, rather than the class of the instance which needs to be
 // checked for mutable fields.
 // TODO: We might as well look at the dynamic type of the object.
-const Expr *Ex = getCXXThisExpr()->ignoreParenBaseCasts();
+const Expr *Ex = getCXXThisExpr()->IgnoreParenBaseCasts();
 QualType T = Ex->getType();
 if (T->isPointerType()) // Arrow or implicit-this syntax?
   T = T->getPointeeType();
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -8375,7 +8375,7 @@
Expr **RHSExprs) {
   // Don't strip parenthesis: we should not warn if E is in parenthesis.
   E = E->IgnoreImpCasts();
-  E = E->IgnoreConversionOperator();
+  E = E->IgnoreConversionOperatorSingleStep();
   E = E->IgnoreImpCasts();
   if (auto *MTE = dyn_cast(E)) {
 E = MTE->getSubExpr();
Index: clang/lib/CodeGen/CGExprCXX.cpp
===
--- clang/lib/CodeGen/CGExprCXX.cpp
+++ clang/lib/CodeGen/CGExprCXX.cpp
@@ -220,7 +220,7 @@
 DevirtualizedMethod = MD->getCorrespondingMethodInClass(BestDynamicDecl);
 assert(DevirtualizedMethod);
 const CXXRecordDecl *DevirtualizedClass = DevirtualizedMethod->getParent();
-const Expr *Inner = Base->ignoreParenBaseCasts();
+const Expr *Inner = Base->IgnoreParenBaseCasts();
 if (DevirtualizedMethod->getReturnType().getCanonicalType() !=
 MD->getReturnType().getCanonicalType())
   // If the return types are not the same, this might be a case where more
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -40,7 +40,7 @@
 const Expr *Expr::getBestDynamicClassTypeExpr() const {
   const Expr *E = this;
   while (true) {
-E = E->ignoreParenBaseCasts();
+E = E->IgnoreParenBaseCasts();
 
 // Follow the RHS of a comma operator.
 if (auto *BO = dyn_cast(E)) {
@@ -2780,29 +2780,6 @@
   return QualType();
 }
 
-static Expr *IgnoreNoopCastsSingleStep(const ASTContext , Expr *E) {
-  if (auto *CE = dyn_cast(E)) {
-// We ignore integer <-> casts that are of the same width, ptr<->ptr and
-// ptr<->int casts of the same width. We also ignore all identity casts.
-Expr *SubExpr = CE->getSubExpr();
-bool IsIdentityCast =
-Ctx.hasSameUnqualifiedType(E->getType(), SubExpr->getType());
-bool IsSameWidthCast =
-(E->getType()->isPointerType() || E->getType()->isIntegralType(Ctx)) &&
-(SubExpr->getType()->isPointerType() ||
- SubExpr->getType()->isIntegralType(Ctx)) &&
-(Ctx.getTypeSize(E->getType()) == Ctx.getTypeSize(SubExpr->getType()));
-
-if (IsIdentityCast || IsSameWidthCast)
-  return SubExpr;
-  }
-
-  else if (auto *NTTP = dyn_cast(E))
-return NTTP->getReplacement();
-
-  return E;
-}
-
 Expr *Expr::IgnoreImpCasts() {
   return IgnoreExprNodes(this, IgnoreImpCastsSingleStep);
 }
@@ -2832,7 +2809,7 @@
   return IgnoreExprNodes(this, IgnoreParensSingleStep, IgnoreCastsSingleStep);
 }
 
-Expr *Expr::IgnoreConversionOperator() {
+Expr *Expr::IgnoreConversionOperatorSingleStep() {
   if (auto *MCE = dyn_cast(this)) {
 if (MCE->getMethodDecl() && isa(MCE->getMethodDecl()))
   return MCE->getImplicitObjectArgument();
@@ -2845,58 +2822,72 @@
  IgnoreLValueCastsSingleStep);
 }
 
-Expr *Expr::ignoreParenBaseCasts() {
+Expr *Expr::IgnoreParenBaseCasts() {
   return IgnoreExprNodes(this, IgnoreParensSingleStep,
  IgnoreBaseCastsSingleStep);
 }
 
 Expr *Expr::IgnoreParenNoopCasts(const ASTContext ) {
-  return IgnoreExprNodes(this, IgnoreParensSingleStep, [](Expr 

[PATCH] D86778: Extract infrastructure to ignore intermediate expressions into `clang/AST/IgnoreExpr.h`

2020-08-31 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 288963.
eduucaldas added a comment.
Herald added a subscriber: mgorny.

Minor lint fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86778

Files:
  clang/include/clang/AST/IgnoreExpr.h
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Expr.cpp
  clang/lib/AST/IgnoreExpr.cpp

Index: clang/lib/AST/IgnoreExpr.cpp
===
--- /dev/null
+++ clang/lib/AST/IgnoreExpr.cpp
@@ -0,0 +1,129 @@
+//===--- IgnoreExpr.cpp - Ignore intermediate Expressions -===//
+//
+// 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
+//
+//===--===//
+//
+// This file implements common functions to ignore intermediate expression nodes
+//
+//===--===//
+
+#include "clang/AST/IgnoreExpr.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+
+using namespace clang;
+
+Expr *clang::IgnoreImpCastsSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast(E))
+return ICE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
+  return E;
+}
+
+Expr *clang::IgnoreImpCastsExtraSingleStep(Expr *E) {
+  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
+  // addition to what IgnoreImpCasts() skips to account for the current
+  // behaviour of IgnoreParenImpCasts().
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
+
+  return E;
+}
+
+Expr *clang::IgnoreCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+return CE->getSubExpr();
+
+  if (auto *FE = dyn_cast(E))
+return FE->getSubExpr();
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *NTTP = dyn_cast(E))
+return NTTP->getReplacement();
+
+  return E;
+}
+
+Expr *clang::IgnoreLValueCastsSingleStep(Expr *E) {
+  // Skip what IgnoreCastsSingleStep skips, except that only
+  // lvalue-to-rvalue casts are skipped.
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() != CK_LValueToRValue)
+  return E;
+
+  return IgnoreCastsSingleStep(E);
+}
+
+Expr *clang::IgnoreBaseCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast(E))
+if (CE->getCastKind() == CK_DerivedToBase ||
+CE->getCastKind() == CK_UncheckedDerivedToBase ||
+CE->getCastKind() == CK_NoOp)
+  return CE->getSubExpr();
+
+  return E;
+}
+
+Expr *clang::IgnoreImplicitSingleStep(Expr *E) {
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
+
+  if (auto *MTE = dyn_cast(E))
+return MTE->getSubExpr();
+
+  if (auto *BTE = dyn_cast(E))
+return BTE->getSubExpr();
+
+  return E;
+}
+
+Expr *clang::IgnoreImplicitAsWrittenSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast(E))
+return ICE->getSubExprAsWritten();
+
+  return IgnoreImplicitSingleStep(E);
+}
+
+Expr *clang::IgnoreParensOnlySingleStep(Expr *E) {
+  if (auto *PE = dyn_cast(E))
+return PE->getSubExpr();
+  return E;
+}
+
+Expr *clang::IgnoreParensSingleStep(Expr *E) {
+  if (auto *PE = dyn_cast(E))
+return PE->getSubExpr();
+
+  if (auto *UO = dyn_cast(E)) {
+if (UO->getOpcode() == UO_Extension)
+  return UO->getSubExpr();
+  }
+
+  else if (auto *GSE = dyn_cast(E)) {
+if (!GSE->isResultDependent())
+  return GSE->getResultExpr();
+  }
+
+  else if (auto *CE = dyn_cast(E)) {
+if (!CE->isConditionDependent())
+  return CE->getChosenSubExpr();
+  }
+
+  return E;
+}
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/DependenceFlags.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/IgnoreExpr.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtVisitor.h"
@@ -2779,118 +2780,6 @@
   return QualType();
 }
 
-static Expr *IgnoreImpCastsSingleStep(Expr *E) {
-  if (auto *ICE = dyn_cast(E))
-return ICE->getSubExpr();
-
-  if (auto *FE = dyn_cast(E))
-return FE->getSubExpr();
-
-  return E;
-}
-
-static Expr *IgnoreImpCastsExtraSingleStep(Expr *E) {
-  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
-  // addition to what IgnoreImpCasts() skips to account for the current
-  // behaviour of IgnoreParenImpCasts().
-  Expr *SubE = IgnoreImpCastsSingleStep(E);
-  if (SubE != E)
-return SubE;
-
-  if (auto *MTE = dyn_cast(E))
-return MTE->getSubExpr();
-
-  if (auto *NTTP = 

[PATCH] D86531: [analyzer][StdLibraryFunctionsChecker][NFC] Use Optionals throughout the summary API

2020-08-31 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 288958.
martong added a comment.

- Rebase to correct base


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86531

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

Index: clang/test/Analysis/std-c-library-functions-POSIX-lookup.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-POSIX-lookup.c
@@ -0,0 +1,22 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true \
+// 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 --allow-empty
+
+// We test here the implementation of our summary API with Optional types. In
+// this TU we do not provide declaration for any of the functions that have
+// summaries. The implementation should be able to handle the nonexistent
+// declarations in a way that the summary is not added to the map. We expect no
+// crashes (i.e. no optionals should be 'dereferenced') and no output.
+
+// Must have at least one call expression to initialize the summary map.
+int bar(void);
+void foo() {
+  bar();
+}
+
+// CHECK-NOT: Loaded summary for:
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -314,7 +314,8 @@
   /// The complete list of constraints that defines a single branch.
   typedef std::vector ConstraintSet;
 
-  using ArgTypes = std::vector;
+  using ArgTypes = std::vector>;
+  using RetType = Optional;
 
   // A placeholder type, we use it whenever we do not care about the concrete
   // type in a Signature.
@@ -324,17 +325,37 @@
   // The signature of a function we want to describe with a summary. This is a
   // concessive signature, meaning there may be irrelevant types in the
   // signature which we do not check against a function with concrete types.
-  struct Signature {
-ArgTypes ArgTys;
+  // All types in the spec need to be canonical.
+  class Signature {
+using ArgQualTypes = std::vector;
+ArgQualTypes ArgTys;
 QualType RetTy;
-Signature(ArgTypes ArgTys, QualType RetTy) : ArgTys(ArgTys), RetTy(RetTy) {
-  assertRetTypeSuitableForSignature(RetTy);
-  for (size_t I = 0, E = ArgTys.size(); I != E; ++I) {
-QualType ArgTy = ArgTys[I];
-assertArgTypeSuitableForSignature(ArgTy);
+// True if any component type is not found by lookup.
+bool Invalid = false;
+
+  public:
+// Construct a signature from optional types. If any of the optional types
+// are not set then the signature will be invalid.
+Signature(ArgTypes ArgTys, RetType RetTy) {
+  for (Optional Arg : ArgTys) {
+if (!Arg) {
+  Invalid = true;
+  return;
+} else {
+  assertArgTypeSuitableForSignature(*Arg);
+  this->ArgTys.push_back(*Arg);
+}
+  }
+  if (!RetTy) {
+Invalid = true;
+return;
+  } else {
+assertRetTypeSuitableForSignature(*RetTy);
+this->RetTy = *RetTy;
   }
 }
 
+bool isInvalid() const { return Invalid; }
 bool matches(const FunctionDecl *FD) const;
 
   private:
@@ -388,6 +409,9 @@
   ///   rules for the given parameter's type, those rules are checked once the
   ///   signature is matched.
   class Summary {
+// FIXME Probably the Signature should not be part of the Summary,
+// We can remove once all overload of addToFunctionSummaryMap requires the
+// Signature explicitly given.
 Optional Sign;
 const InvalidationKind InvalidationKd;
 Cases CaseConstraints;
@@ -398,11 +422,13 @@
 const FunctionDecl *FD = nullptr;
 
   public:
-Summary(ArgTypes ArgTys, QualType RetTy, InvalidationKind InvalidationKd)
+Summary(ArgTypes ArgTys, RetType RetTy, InvalidationKind InvalidationKd)
 : Sign(Signature(ArgTys, RetTy)), InvalidationKd(InvalidationKd) {}
 
 Summary(InvalidationKind InvalidationKd) : InvalidationKd(InvalidationKd) {}
 
+// FIXME Remove, once all overload of addToFunctionSummaryMap requires the
+// Signature explicitly given.
 Summary (const Signature ) {
   Sign = S;
   return *this;
@@ -438,6 +464,13 @@
   return Result;
 }
 
+// FIXME Remove, once all overload of addToFunctionSummaryMap requires the
+// Signature explicitly given.
+bool hasInvalidSignature() {
+  

[PATCH] D86858: [OpenMP] Fix infinite loop in Sema::isOpenMPGlobalCapturedDecl()

2020-08-31 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

LG, @ABataev ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86858

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


[PATCH] D86531: [analyzer][StdLibraryFunctionsChecker][NFC] Use Optionals throughout the summary API

2020-08-31 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 288957.
martong added a comment.

- Revert "Add assert in getRanges"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86531

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-POSIX-lookup.c
  clang/test/Analysis/std-c-library-functions-POSIX-socket-sockaddr.cpp
  clang/test/Analysis/std-c-library-functions-POSIX.c

Index: clang/test/Analysis/std-c-library-functions-POSIX.c
===
--- clang/test/Analysis/std-c-library-functions-POSIX.c
+++ clang/test/Analysis/std-c-library-functions-POSIX.c
@@ -79,6 +79,22 @@
 // CHECK: Loaded summary for: int execv(const char *path, char *const argv[])
 // CHECK: Loaded summary for: int execvp(const char *file, char *const argv[])
 // CHECK: Loaded summary for: int getopt(int argc, char *const argv[], const char *optstring)
+// CHECK: Loaded summary for: int accept(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: int bind(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len)
+// CHECK: Loaded summary for: int getpeername(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: int getsockname(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: int connect(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len)
+// CHECK: Loaded summary for: ssize_t recvfrom(int socket, void *restrict buffer, size_t length, int flags, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: ssize_t sendto(int socket, const void *message, size_t length, int flags, __CONST_SOCKADDR_ARG dest_addr, socklen_t dest_len)
+// CHECK: Loaded summary for: int listen(int sockfd, int backlog)
+// CHECK: Loaded summary for: ssize_t recv(int sockfd, void *buf, size_t len, int flags)
+// CHECK: Loaded summary for: ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags)
+// CHECK: Loaded summary for: ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags)
+// CHECK: Loaded summary for: int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len)
+// CHECK: Loaded summary for: int getsockopt(int socket, int level, int option_name, void *restrict option_value, socklen_t *restrict option_len)
+// CHECK: Loaded summary for: ssize_t send(int sockfd, const void *buf, size_t len, int flags)
+// CHECK: Loaded summary for: int socketpair(int domain, int type, int protocol, int sv[2])
+// CHECK: Loaded summary for: int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, char *restrict node, socklen_t nodelen, char *restrict service, socklen_t servicelen, int flags)
 
 long a64l(const char *str64);
 char *l64a(long value);
@@ -171,6 +187,46 @@
 int execvp(const char *file, char *const argv[]);
 int getopt(int argc, char *const argv[], const char *optstring);
 
+// In some libc implementations, sockaddr parameter is a transparent
+// union of the underlying sockaddr_ pointers instead of being a
+// pointer to struct sockaddr.
+// We match that with the joker Irrelevant type.
+struct sockaddr;
+struct sockaddr_at;
+#define __SOCKADDR_ALLTYPES\
+  __SOCKADDR_ONETYPE(sockaddr) \
+  __SOCKADDR_ONETYPE(sockaddr_at)
+#define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;
+typedef union {
+  __SOCKADDR_ALLTYPES
+} __SOCKADDR_ARG __attribute__((__transparent_union__));
+#undef __SOCKADDR_ONETYPE
+#define __SOCKADDR_ONETYPE(type) const struct type *__restrict __##type##__;
+typedef union {
+  __SOCKADDR_ALLTYPES
+} __CONST_SOCKADDR_ARG __attribute__((__transparent_union__));
+#undef __SOCKADDR_ONETYPE
+typedef unsigned socklen_t;
+
+int accept(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+int bind(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len);
+int getpeername(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+int getsockname(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+int connect(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len);
+ssize_t recvfrom(int socket, void *restrict buffer, size_t length, int flags, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+ssize_t sendto(int socket, const void *message, size_t length, int flags, __CONST_SOCKADDR_ARG dest_addr, socklen_t dest_len);
+
+int listen(int sockfd, int backlog);
+ssize_t recv(int sockfd, void *buf, size_t len, int flags);
+struct msghdr;
+ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags);
+ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);
+int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len);
+int getsockopt(int socket, int level, int option_name, void 

[PATCH] D86877: [Clang][Driver] Support per-target runtime directories in the bare-metal toolchain

2020-08-31 Thread Raul Tambre via Phabricator via cfe-commits
tambre updated this revision to Diff 288956.
tambre added a comment.

Add missing dash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86877

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/ToolChains/BareMetal.cpp


Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -156,8 +156,12 @@
 
 void BareMetal::AddLinkRuntimeLib(const ArgList ,
   ArgStringList ) const {
-  CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins-" +
-   getTriple().getArchName()));
+#ifdef PER_TARGET_RUNTIME_DIR
+  CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins"));
+#else
+  CmdArgs.push_back(
+  Args.MakeArgString("-lclang_rt.builtins-" + getTriple().getArchName()));
+#endif
 }
 
 void baremetal::Linker::ConstructJob(Compilation , const JobAction ,
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -83,3 +83,7 @@
   clangBasic
   ${system_libs}
   )
+
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
+  set_source_files_properties(ToolChains/BareMetal.cpp PROPERTIES 
COMPILE_DEFINITIONS "PER_TARGET_RUNTIME_DIR")
+endif()


Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -156,8 +156,12 @@
 
 void BareMetal::AddLinkRuntimeLib(const ArgList ,
   ArgStringList ) const {
-  CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins-" +
-   getTriple().getArchName()));
+#ifdef PER_TARGET_RUNTIME_DIR
+  CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins"));
+#else
+  CmdArgs.push_back(
+  Args.MakeArgString("-lclang_rt.builtins-" + getTriple().getArchName()));
+#endif
 }
 
 void baremetal::Linker::ConstructJob(Compilation , const JobAction ,
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -83,3 +83,7 @@
   clangBasic
   ${system_libs}
   )
+
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
+  set_source_files_properties(ToolChains/BareMetal.cpp PROPERTIES COMPILE_DEFINITIONS "PER_TARGET_RUNTIME_DIR")
+endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86531: [analyzer][StdLibraryFunctionsChecker][NFC] Use Optionals throughout the summary API

2020-08-31 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Just realized. There maybe cases when we'd like to give XMax to an arg 
constraint, but the type of the arg is Y (X may be a looked up type). One 
example for such is getchar, where the return type is Int, but we have a range 
constraint {0, UCharRangeMax}. Consequently, it seems to be better to remove 
the assert, because we will not be able to handle such cases with looked up 
types and their max values.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86531

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


[PATCH] D86877: [Clang][Driver] Support per-target runtime directories in the bare-metal toolchain

2020-08-31 Thread Raul Tambre via Phabricator via cfe-commits
tambre created this revision.
tambre added a reviewer: phosek.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
tambre requested review of this revision.

When LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is set to ON the clang_rt.builtins will
not have an architecture prefix and will be placed instead in an architecture
directory.
This causes issues with the bare-metal toolchain, which assumes the suffixed
variant.

Add a define dependent on LLVM_ENABLE_PER_TARGET_RUNTIME_DIR, which switches
the bare-metal toolchain to use the unsuffixed version if enabled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86877

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/ToolChains/BareMetal.cpp


Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -156,8 +156,12 @@
 
 void BareMetal::AddLinkRuntimeLib(const ArgList ,
   ArgStringList ) const {
-  CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins-" +
-   getTriple().getArchName()));
+#ifdef PER_TARGET_RUNTIME_DIR
+  CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins"));
+#else
+  CmdArgs.push_back(
+  Args.MakeArgString("-lclang_rt.builtins" + getTriple().getArchName()));
+#endif
 }
 
 void baremetal::Linker::ConstructJob(Compilation , const JobAction ,
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -83,3 +83,7 @@
   clangBasic
   ${system_libs}
   )
+
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
+  set_source_files_properties(ToolChains/BareMetal.cpp PROPERTIES 
COMPILE_DEFINITIONS "PER_TARGET_RUNTIME_DIR")
+endif()


Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -156,8 +156,12 @@
 
 void BareMetal::AddLinkRuntimeLib(const ArgList ,
   ArgStringList ) const {
-  CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins-" +
-   getTriple().getArchName()));
+#ifdef PER_TARGET_RUNTIME_DIR
+  CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins"));
+#else
+  CmdArgs.push_back(
+  Args.MakeArgString("-lclang_rt.builtins" + getTriple().getArchName()));
+#endif
 }
 
 void baremetal::Linker::ConstructJob(Compilation , const JobAction ,
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -83,3 +83,7 @@
   clangBasic
   ${system_libs}
   )
+
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
+  set_source_files_properties(ToolChains/BareMetal.cpp PROPERTIES COMPILE_DEFINITIONS "PER_TARGET_RUNTIME_DIR")
+endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-08-31 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added inline comments.



Comment at: compiler-rt/lib/builtins/fp_div_impl.inc:109
+
+#if NUMBER_OF_HALF_ITERATIONS > 0
+  // Starting with (n-1) half-width iterations

scanon wrote:
> sepavloff wrote:
> > atrosinenko wrote:
> > > sepavloff wrote:
> > > > It is good optimization. Could you please put a comment shortly 
> > > > describing the idea of using half-sized temporaries?
> > > The idea is just "I guess this takes less CPU time and I have managed to 
> > > prove error bounds for it". :) Specifically, for float128, the rep_t * 
> > > rep_t multiplication will be emulated with lots of CPU instructions while 
> > > the lower half contain some noise at that point. This particular 
> > > optimization did exist in the original implementation for float64 and 
> > > float128. For float32 it had not much sense, I guess. Still, estimations 
> > > were calculated for the case of float32 with half-size iterations as it 
> > > may be useful for MSP430 and other 16-bit targets.
> > The idea is clear but it require some study of the sources. I would propose 
> > to add a comment saying:
> > ```
> > At the first iterations number of significant digits is small, so we may 
> > use shorter type values. Operations on them are usually faster.
> > ```
> > or something like that.
> This is absolutely standard in HW construction of pipelined iterative 
> dividers and square root units, so I'm not sure how much explanation is 
> really needed =)
> This is absolutely standard in HW construction of pipelined iterative 
> dividers and square root units, so I'm not sure how much explanation is 
> really needed =)

I think now the code has enough explanations to be easily understood by mere 
mortals also :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85031

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


[clang-tools-extra] 22808d6 - [clang-tidy] Buildbot failure fix for commit rGf5fd7486d6c0

2020-08-31 Thread Adam Balogh via cfe-commits

Author: Adam Balogh
Date: 2020-08-31T16:32:10+02:00
New Revision: 22808d693ef7f8cf61ceff506a320249a0bdb5ef

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

LOG: [clang-tidy] Buildbot failure fix for commit rGf5fd7486d6c0

Commit `rGf5fd7486d6c0` caused a buildbot failure because exceptions are
disabled by default on one of the buildbots. This patch forcibly enables
exceptions for the affected test.

Added: 


Modified: 

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
index c65b6374ace2..a55a7d8208a6 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-prefer-member-initializer %t
+// RUN: %check_clang_tidy %s cppcoreguidelines-prefer-member-initializer %t -- 
-- -fcxx-exceptions
 
 class Simple1 {
   int n;



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


[PATCH] D86531: [analyzer][StdLibraryFunctionsChecker][NFC] Use Optionals throughout the summary API

2020-08-31 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1006
+return IntRangeVector{std::pair{b, *e}};
+  return IntRangeVector{};
+}

balazske wrote:
> This return of empty vector and possibility of adding empty vector to range 
> constraint is a new thing, probably it is better to check at create of range 
> constraint (or other place) for empty range (in this case the summary could 
> be made invalid)? But this occurs probably never because the matching type 
> (of the max value) should be used at the same function and if the type is 
> there the max value should be too.
Alright, I added an assert to RangeConstraint::getRanges:
```
 const IntRangeVector () const {
+  // When using max values for a type, the type normally should be part of
+  // the signature. Thus we must had looked up previously the type. If the
+  // type is not found then the range would be empty, but then the summary
+  // should be invalid too.
+  assert(Args.size() && "Empty range is meaningless");
   return Args;
 }
```



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1321
 
-Optional Mode_tTy = lookupType("mode_t", ACtx);
+Optional Mode_tTy = lookupTy("mode_t");
 

balazske wrote:
> martong wrote:
> > balazske wrote:
> > > It is better to get every type at the start before adding functions, or 
> > > group the functions and get some types at the start of these groups but 
> > > mark the groups at least with comments.
> > Well, with looked-up types I followed the usual convention to define a 
> > variable right before using it. This means that we lookup a type just 
> > before we try to add the function which first uses that type.
> > 
> > However, builtin types are defined at the beginning, because they are used 
> > very often.
> I still like it better if all the type variables are created at one place 
> (can be more easy to maintain if order changes and we have one block of types 
> and one of functions) but this is no reason to block this change.
I see your point, still I'd keep this way, because I this way the functions and 
the types they use are close to each other in the source.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86531

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


[PATCH] D86531: [analyzer][StdLibraryFunctionsChecker][NFC] Use Optionals throughout the summary API

2020-08-31 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 288946.
martong added a comment.

- Add assert in getRanges


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86531

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

Index: clang/test/Analysis/std-c-library-functions-POSIX-lookup.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-POSIX-lookup.c
@@ -0,0 +1,22 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true \
+// 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 --allow-empty
+
+// We test here the implementation of our summary API with Optional types. In
+// this TU we do not provide declaration for any of the functions that have
+// summaries. The implementation should be able to handle the nonexistent
+// declarations in a way that the summary is not added to the map. We expect no
+// crashes (i.e. no optionals should be 'dereferenced') and no output.
+
+// Must have at least one call expression to initialize the summary map.
+int bar(void);
+void foo() {
+  bar();
+}
+
+// CHECK-NOT: Loaded summary for:
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -148,6 +148,11 @@
 : ValueConstraint(ArgN), Kind(Kind), Args(Args) {}
 
 const IntRangeVector () const {
+  // When using max values for a type, the type normally should be part of
+  // the signature. Thus we must had looked up previously the type. If the
+  // type is not found then the range would be empty, but then the summary
+  // should be invalid too.
+  assert(Args.size() && "Empty range is meaningless");
   return Args;
 }
 
@@ -314,7 +319,8 @@
   /// The complete list of constraints that defines a single branch.
   typedef std::vector ConstraintSet;
 
-  using ArgTypes = std::vector;
+  using ArgTypes = std::vector>;
+  using RetType = Optional;
 
   // A placeholder type, we use it whenever we do not care about the concrete
   // type in a Signature.
@@ -324,17 +330,37 @@
   // The signature of a function we want to describe with a summary. This is a
   // concessive signature, meaning there may be irrelevant types in the
   // signature which we do not check against a function with concrete types.
-  struct Signature {
-ArgTypes ArgTys;
+  // All types in the spec need to be canonical.
+  class Signature {
+using ArgQualTypes = std::vector;
+ArgQualTypes ArgTys;
 QualType RetTy;
-Signature(ArgTypes ArgTys, QualType RetTy) : ArgTys(ArgTys), RetTy(RetTy) {
-  assertRetTypeSuitableForSignature(RetTy);
-  for (size_t I = 0, E = ArgTys.size(); I != E; ++I) {
-QualType ArgTy = ArgTys[I];
-assertArgTypeSuitableForSignature(ArgTy);
+// True if any component type is not found by lookup.
+bool Invalid = false;
+
+  public:
+// Construct a signature from optional types. If any of the optional types
+// are not set then the signature will be invalid.
+Signature(ArgTypes ArgTys, RetType RetTy) {
+  for (Optional Arg : ArgTys) {
+if (!Arg) {
+  Invalid = true;
+  return;
+} else {
+  assertArgTypeSuitableForSignature(*Arg);
+  this->ArgTys.push_back(*Arg);
+}
+  }
+  if (!RetTy) {
+Invalid = true;
+return;
+  } else {
+assertRetTypeSuitableForSignature(*RetTy);
+this->RetTy = *RetTy;
   }
 }
 
+bool isInvalid() const { return Invalid; }
 bool matches(const FunctionDecl *FD) const;
 
   private:
@@ -388,6 +414,9 @@
   ///   rules for the given parameter's type, those rules are checked once the
   ///   signature is matched.
   class Summary {
+// FIXME Probably the Signature should not be part of the Summary,
+// We can remove once all overload of addToFunctionSummaryMap requires the
+// Signature explicitly given.
 Optional Sign;
 const InvalidationKind InvalidationKd;
 Cases CaseConstraints;
@@ -398,11 +427,13 @@
 const FunctionDecl *FD = nullptr;
 
   public:
-Summary(ArgTypes ArgTys, QualType RetTy, InvalidationKind InvalidationKd)
+Summary(ArgTypes ArgTys, RetType RetTy, InvalidationKind InvalidationKd)
 : Sign(Signature(ArgTys, RetTy)), InvalidationKd(InvalidationKd) {}
 
 

[PATCH] D86854: [CodeGen] Make sure the EH cleanup for block captures is conditional when the block literal is in a conditional context

2020-08-31 Thread Erik Pilkington via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa9a6e62ddff2: [CodeGen] Make sure the EH cleanup for block 
captures is conditional when the… (authored by erik.pilkington).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D86854?vs=288871=288945#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86854

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenObjC/arc-blocks-exceptions.m

Index: clang/test/CodeGenObjC/arc-blocks-exceptions.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/arc-blocks-exceptions.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -fexceptions -disable-llvm-passes -o - %s | FileCheck %s
+
+void test1(_Bool c) {
+  void test1_fn(void (^blk)());
+  __weak id weakId = 0;
+  test1_fn(c ? ^{ (void)weakId; } : 0);
+
+  // CHECK: [[CLEANUP_COND:%.*]] = alloca i1
+  // CHECK-NEXT: [[CLEANUP_SAVE:%.*]] = alloca i8**
+
+  // CHECK: store i1 true, i1* [[CLEANUP_COND]]
+  // CHECK-NEXT: store i8** {{.*}}, i8*** [[CLEANUP_SAVE]]
+
+  // CHECK: invoke void @test1_fn(
+  // CHECK-NEXT: to label %[[INVOKE_CONT:.*]] unwind label %[[LANDING_PAD_LAB:.*]]
+
+  // CHECK: [[INVOKE_CONT]]:
+  // CHECK-NEXT: [[LOAD:%.*]] = load i1, i1* [[CLEANUP_COND]]
+  // CHECK-NEXT: br i1 [[LOAD]], label %[[END_OF_SCOPE_LAB:.*]], label
+
+  // CHECK: [[END_OF_SCOPE_LAB]]:
+  // CHECK-NEXT: [[LOAD:%.*]] = load i8**, i8*** [[CLEANUP_SAVE]]
+  // CHECK-NEXT: call void @llvm.objc.destroyWeak(i8** [[LOAD]])
+  // CHECK-NEXT: br label
+
+  // CHECK: [[LANDING_PAD_LAB]]:
+  //   /* some EH stuff */
+  // CHECK:  [[LOAD:%.*]] = load i1, i1* [[CLEANUP_COND]]
+  // CHECK-NEXT: br i1 [[LOAD]], label %[[EH_CLEANUP_LAB:.*]], label
+
+  // CHECK: [[EH_CLEANUP_LAB]]:
+  // CHECK-NEXT: [[LOAD:%.*]] = load i8**, i8*** [[CLEANUP_SAVE]]
+  // CHECK-NEXT: call void @llvm.objc.destroyWeak(i8** [[LOAD]])
+  // CHECK-NEXT: br label
+}
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -672,12 +672,13 @@
 initFullExprCleanup();
   }
 
-  /// Queue a cleanup to be pushed after finishing the current
-  /// full-expression.
+  /// Queue a cleanup to be pushed after finishing the current full-expression,
+  /// potentially with an active flag.
   template 
   void pushCleanupAfterFullExpr(CleanupKind Kind, As... A) {
 if (!isInConditionalBranch())
-  return pushCleanupAfterFullExprImpl(Kind, Address::invalid(), A...);
+  return pushCleanupAfterFullExprWithActiveFlag(Kind, Address::invalid(),
+   A...);
 
 Address ActiveFlag = createCleanupActiveFlag();
 assert(!DominatingValue::needsSaving(ActiveFlag) &&
@@ -687,12 +688,12 @@
 SavedTuple Saved{saveValueInCond(A)...};
 
 typedef EHScopeStack::ConditionalCleanup CleanupType;
-pushCleanupAfterFullExprImpl(Kind, ActiveFlag, Saved);
+pushCleanupAfterFullExprWithActiveFlag(Kind, ActiveFlag, Saved);
   }
 
   template 
-  void pushCleanupAfterFullExprImpl(CleanupKind Kind, Address ActiveFlag,
-As... A) {
+  void pushCleanupAfterFullExprWithActiveFlag(CleanupKind Kind,
+  Address ActiveFlag, As... A) {
 LifetimeExtendedCleanupHeader Header = {sizeof(T), Kind,
 ActiveFlag.isValid()};
 
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -2095,21 +2095,47 @@
   EHStack.pushCleanup(Kind, SPMem);
 }
 
-void CodeGenFunction::pushLifetimeExtendedDestroy(
-CleanupKind cleanupKind, Address addr, QualType type,
-Destroyer *destroyer, bool useEHCleanupForArray) {
-  // Push an EH-only cleanup for the object now.
-  // FIXME: When popping normal cleanups, we need to keep this EH cleanup
-  // around in case a temporary's destructor throws an exception.
-  if (cleanupKind & EHCleanup)
-EHStack.pushCleanup(
-static_cast(cleanupKind & ~NormalCleanup), addr, type,
+void CodeGenFunction::pushLifetimeExtendedDestroy(CleanupKind cleanupKind,
+  Address addr, QualType type,
+  Destroyer *destroyer,
+  bool useEHCleanupForArray) {
+  // If we're not in a conditional branch, we don't need to bother generating a
+  // conditional cleanup.
+  if (!isInConditionalBranch()) {
+// Push an EH-only cleanup for the object now.
+// FIXME: When 

[clang] a9a6e62 - [CodeGen] Make sure the EH cleanup for block captures is conditional when the block literal is in a conditional context

2020-08-31 Thread Erik Pilkington via cfe-commits

Author: Erik Pilkington
Date: 2020-08-31T10:12:17-04:00
New Revision: a9a6e62ddff21c597b82f0f6d26bca6a1a473a6f

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

LOG: [CodeGen] Make sure the EH cleanup for block captures is conditional when 
the block literal is in a conditional context

Previously, clang was crashing on the attached test because the EH cleanup for
the block capture was incorrectly emitted under the assumption that the
expression wasn't conditionally evaluated. This was because before 9a52de00260,
pushLifetimeExtendedDestroy was mainly used with C++ automatic lifetime
extension, where a conditionally evaluated expression wasn't possible. Now that
we're using this path for block captures, we need to handle this case.

rdar://66250047

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

Added: 
clang/test/CodeGenObjC/arc-blocks-exceptions.m

Modified: 
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 0ad5050fabbb..7daf91ff73e3 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -2095,21 +2095,47 @@ void CodeGenFunction::pushStackRestore(CleanupKind 
Kind, Address SPMem) {
   EHStack.pushCleanup(Kind, SPMem);
 }
 
-void CodeGenFunction::pushLifetimeExtendedDestroy(
-CleanupKind cleanupKind, Address addr, QualType type,
-Destroyer *destroyer, bool useEHCleanupForArray) {
-  // Push an EH-only cleanup for the object now.
-  // FIXME: When popping normal cleanups, we need to keep this EH cleanup
-  // around in case a temporary's destructor throws an exception.
-  if (cleanupKind & EHCleanup)
-EHStack.pushCleanup(
-static_cast(cleanupKind & ~NormalCleanup), addr, type,
+void CodeGenFunction::pushLifetimeExtendedDestroy(CleanupKind cleanupKind,
+  Address addr, QualType type,
+  Destroyer *destroyer,
+  bool useEHCleanupForArray) {
+  // If we're not in a conditional branch, we don't need to bother generating a
+  // conditional cleanup.
+  if (!isInConditionalBranch()) {
+// Push an EH-only cleanup for the object now.
+// FIXME: When popping normal cleanups, we need to keep this EH cleanup
+// around in case a temporary's destructor throws an exception.
+if (cleanupKind & EHCleanup)
+  EHStack.pushCleanup(
+  static_cast(cleanupKind & ~NormalCleanup), addr, type,
+  destroyer, useEHCleanupForArray);
+
+return pushCleanupAfterFullExprWithActiveFlag(
+cleanupKind, Address::invalid(), addr, type, destroyer, 
useEHCleanupForArray);
+  }
+
+  // Otherwise, we should only destroy the object if it's been initialized.
+  // Re-use the active flag and saved address across both the EH and end of
+  // scope cleanups.
+
+  using SavedType = typename DominatingValue::saved_type;
+  using ConditionalCleanupType =
+  EHScopeStack::ConditionalCleanup;
+
+  Address ActiveFlag = createCleanupActiveFlag();
+  SavedType SavedAddr = saveValueInCond(addr);
+
+  if (cleanupKind & EHCleanup) {
+EHStack.pushCleanup(
+static_cast(cleanupKind & ~NormalCleanup), SavedAddr, 
type,
 destroyer, useEHCleanupForArray);
+initFullExprCleanupWithFlag(ActiveFlag);
+  }
 
-  // Remember that we need to push a full cleanup for the object at the
-  // end of the full-expression.
-  pushCleanupAfterFullExpr(
-  cleanupKind, addr, type, destroyer, useEHCleanupForArray);
+  pushCleanupAfterFullExprWithActiveFlag(
+  cleanupKind, ActiveFlag, SavedAddr, type, destroyer,
+  useEHCleanupForArray);
 }
 
 /// emitDestroy - Immediately perform the destruction of the given

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 77671b0a9952..b4f8b11c0cd3 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -672,12 +672,13 @@ class CodeGenFunction : public CodeGenTypeCache {
 initFullExprCleanup();
   }
 
-  /// Queue a cleanup to be pushed after finishing the current
-  /// full-expression.
+  /// Queue a cleanup to be pushed after finishing the current full-expression,
+  /// potentially with an active flag.
   template 
   void pushCleanupAfterFullExpr(CleanupKind Kind, As... A) {
 if (!isInConditionalBranch())
-  return pushCleanupAfterFullExprImpl(Kind, Address::invalid(), A...);
+  return pushCleanupAfterFullExprWithActiveFlag(Kind, 
Address::invalid(),
+   A...);
 
 Address ActiveFlag = createCleanupActiveFlag();
 assert(!DominatingValue::needsSaving(ActiveFlag) &&

[PATCH] D86218: Teach the swift calling convention about _Atomic types

2020-08-31 Thread Arnold Schwaighofer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG41634497d4fd: Teach the swift calling convention about 
_Atomic types (authored by aschwaighofer).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86218

Files:
  clang/lib/CodeGen/SwiftCallingConv.cpp
  clang/test/CodeGen/64bit-swiftcall.c


Index: clang/test/CodeGen/64bit-swiftcall.c
===
--- clang/test/CodeGen/64bit-swiftcall.c
+++ clang/test/CodeGen/64bit-swiftcall.c
@@ -10,6 +10,9 @@
 #define ERROR __attribute__((swift_error_result))
 #define CONTEXT __attribute__((swift_context))
 
+// CHECK-DAG: %struct.atomic_padded = type { { %struct.packed, [7 x i8] } }
+// CHECK-DAG: %struct.packed = type <{ i64, i8 }>
+//
 // CHECK: [[STRUCT2_RESULT:@.*]] = private {{.*}} constant 
[[STRUCT2_TYPE:%.*]] { i32 0, i8 0, i8 undef, i8 0, i32 0, i32 0 }
 
 /*/
@@ -1042,3 +1045,27 @@
   // CHECK-NOT: call void @llvm.lifetime.
   take_int5(return_int5());
 }
+
+typedef struct {
+  unsigned long long a;
+  unsigned long long b;
+} double_word;
+
+typedef struct {
+  _Atomic(double_word) a;
+} atomic_double_word;
+
+// CHECK-LABEL: use_atomic(i64 %0, i64 %1)
+SWIFTCALL void use_atomic(atomic_double_word a) {}
+
+typedef struct {
+  unsigned long long a;
+  unsigned char b;
+} __attribute__((packed)) packed;
+
+typedef struct {
+  _Atomic(packed) a;
+} atomic_padded;
+
+// CHECK-LABEL: use_atomic_padded(i64 %0, i64 %1)
+SWIFTCALL void use_atomic_padded(atomic_padded a) {}
Index: clang/lib/CodeGen/SwiftCallingConv.cpp
===
--- clang/lib/CodeGen/SwiftCallingConv.cpp
+++ clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -93,11 +93,24 @@
 // Just add it all as opaque.
 addOpaqueData(begin, begin + CGM.getContext().getTypeSizeInChars(type));
 
-  // Everything else is scalar and should not convert as an LLVM aggregate.
+// Atomic types.
+  } else if (const auto *atomicType = type->getAs()) {
+auto valueType = atomicType->getValueType();
+auto atomicSize = CGM.getContext().getTypeSizeInChars(atomicType);
+auto valueSize = CGM.getContext().getTypeSizeInChars(valueType);
+
+addTypedData(atomicType->getValueType(), begin);
+
+// Add atomic padding.
+auto atomicPadding = atomicSize - valueSize;
+if (atomicPadding > CharUnits::Zero())
+  addOpaqueData(begin + valueSize, begin + atomicSize);
+
+// Everything else is scalar and should not convert as an LLVM aggregate.
   } else {
 // We intentionally convert as !ForMem because we want to preserve
 // that a type was an i1.
-auto llvmType = CGM.getTypes().ConvertType(type);
+auto *llvmType = CGM.getTypes().ConvertType(type);
 addTypedData(llvmType, begin);
   }
 }


Index: clang/test/CodeGen/64bit-swiftcall.c
===
--- clang/test/CodeGen/64bit-swiftcall.c
+++ clang/test/CodeGen/64bit-swiftcall.c
@@ -10,6 +10,9 @@
 #define ERROR __attribute__((swift_error_result))
 #define CONTEXT __attribute__((swift_context))
 
+// CHECK-DAG: %struct.atomic_padded = type { { %struct.packed, [7 x i8] } }
+// CHECK-DAG: %struct.packed = type <{ i64, i8 }>
+//
 // CHECK: [[STRUCT2_RESULT:@.*]] = private {{.*}} constant [[STRUCT2_TYPE:%.*]] { i32 0, i8 0, i8 undef, i8 0, i32 0, i32 0 }
 
 /*/
@@ -1042,3 +1045,27 @@
   // CHECK-NOT: call void @llvm.lifetime.
   take_int5(return_int5());
 }
+
+typedef struct {
+  unsigned long long a;
+  unsigned long long b;
+} double_word;
+
+typedef struct {
+  _Atomic(double_word) a;
+} atomic_double_word;
+
+// CHECK-LABEL: use_atomic(i64 %0, i64 %1)
+SWIFTCALL void use_atomic(atomic_double_word a) {}
+
+typedef struct {
+  unsigned long long a;
+  unsigned char b;
+} __attribute__((packed)) packed;
+
+typedef struct {
+  _Atomic(packed) a;
+} atomic_padded;
+
+// CHECK-LABEL: use_atomic_padded(i64 %0, i64 %1)
+SWIFTCALL void use_atomic_padded(atomic_padded a) {}
Index: clang/lib/CodeGen/SwiftCallingConv.cpp
===
--- clang/lib/CodeGen/SwiftCallingConv.cpp
+++ clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -93,11 +93,24 @@
 // Just add it all as opaque.
 addOpaqueData(begin, begin + CGM.getContext().getTypeSizeInChars(type));
 
-  // Everything else is scalar and should not convert as an LLVM aggregate.
+// Atomic types.
+  } else if (const auto *atomicType = type->getAs()) {
+auto valueType = atomicType->getValueType();
+auto atomicSize = CGM.getContext().getTypeSizeInChars(atomicType);
+auto valueSize = CGM.getContext().getTypeSizeInChars(valueType);
+
+addTypedData(atomicType->getValueType(), begin);
+
+// Add 

[clang] 4163449 - Teach the swift calling convention about _Atomic types

2020-08-31 Thread Arnold Schwaighofer via cfe-commits

Author: Arnold Schwaighofer
Date: 2020-08-31T07:07:25-07:00
New Revision: 41634497d4fd21f28d08ac6f538ca4045f386c95

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

LOG: Teach the swift calling convention about _Atomic types

rdar://67351073

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

Added: 


Modified: 
clang/lib/CodeGen/SwiftCallingConv.cpp
clang/test/CodeGen/64bit-swiftcall.c

Removed: 




diff  --git a/clang/lib/CodeGen/SwiftCallingConv.cpp 
b/clang/lib/CodeGen/SwiftCallingConv.cpp
index cbbe208426f7..1d712f4fde3c 100644
--- a/clang/lib/CodeGen/SwiftCallingConv.cpp
+++ b/clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -93,11 +93,24 @@ void SwiftAggLowering::addTypedData(QualType type, 
CharUnits begin) {
 // Just add it all as opaque.
 addOpaqueData(begin, begin + CGM.getContext().getTypeSizeInChars(type));
 
-  // Everything else is scalar and should not convert as an LLVM aggregate.
+// Atomic types.
+  } else if (const auto *atomicType = type->getAs()) {
+auto valueType = atomicType->getValueType();
+auto atomicSize = CGM.getContext().getTypeSizeInChars(atomicType);
+auto valueSize = CGM.getContext().getTypeSizeInChars(valueType);
+
+addTypedData(atomicType->getValueType(), begin);
+
+// Add atomic padding.
+auto atomicPadding = atomicSize - valueSize;
+if (atomicPadding > CharUnits::Zero())
+  addOpaqueData(begin + valueSize, begin + atomicSize);
+
+// Everything else is scalar and should not convert as an LLVM aggregate.
   } else {
 // We intentionally convert as !ForMem because we want to preserve
 // that a type was an i1.
-auto llvmType = CGM.getTypes().ConvertType(type);
+auto *llvmType = CGM.getTypes().ConvertType(type);
 addTypedData(llvmType, begin);
   }
 }

diff  --git a/clang/test/CodeGen/64bit-swiftcall.c 
b/clang/test/CodeGen/64bit-swiftcall.c
index 51fb8545551f..5843b8cde4dc 100644
--- a/clang/test/CodeGen/64bit-swiftcall.c
+++ b/clang/test/CodeGen/64bit-swiftcall.c
@@ -10,6 +10,9 @@
 #define ERROR __attribute__((swift_error_result))
 #define CONTEXT __attribute__((swift_context))
 
+// CHECK-DAG: %struct.atomic_padded = type { { %struct.packed, [7 x i8] } }
+// CHECK-DAG: %struct.packed = type <{ i64, i8 }>
+//
 // CHECK: [[STRUCT2_RESULT:@.*]] = private {{.*}} constant 
[[STRUCT2_TYPE:%.*]] { i32 0, i8 0, i8 undef, i8 0, i32 0, i32 0 }
 
 /*/
@@ -1042,3 +1045,27 @@ void no_lifetime_markers() {
   // CHECK-NOT: call void @llvm.lifetime.
   take_int5(return_int5());
 }
+
+typedef struct {
+  unsigned long long a;
+  unsigned long long b;
+} double_word;
+
+typedef struct {
+  _Atomic(double_word) a;
+} atomic_double_word;
+
+// CHECK-LABEL: use_atomic(i64 %0, i64 %1)
+SWIFTCALL void use_atomic(atomic_double_word a) {}
+
+typedef struct {
+  unsigned long long a;
+  unsigned char b;
+} __attribute__((packed)) packed;
+
+typedef struct {
+  _Atomic(packed) a;
+} atomic_padded;
+
+// CHECK-LABEL: use_atomic_padded(i64 %0, i64 %1)
+SWIFTCALL void use_atomic_padded(atomic_padded a) {}



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


[PATCH] D86707: [SystemZ][z/OS] Adding initial toolchain for z/OS

2020-08-31 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked an inline comment as done.
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Driver/ToolChains/ZOS.h:25
+
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }

hubert.reinterpretcast wrote:
> According to the RFC re: LLVM on z/OS, the initial support in LLVM for z/OS 
> is only for XPLink. My understanding is that all XPLink applications are 
> DLL-enabled. Does being DLL-enabled not imply that the code is 
> position-independent?
> 
> I understand that the value of the `__DLL__` predefined macro from the XL C 
> compiler does not reflect the implicit DLL-enablement of XPLink code; 
> however, I also note that the same compiler claims falsely that `Option NODLL 
> is ignored because option XPLINK is specified` when `-qnodll` does actually 
> suppress the effect of an earlier `-qdll` in causing `__DLL__` to be defined.
This is not always true because we do not require code to be PIC on z/OS, even 
for XPLink applications. Absolute addresses may be present in code sections for 
easier access (e.g. in calls to linkages, branch tables). We also may link to 
libraries that contain non-PIC code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86707

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


[clang-tools-extra] 14dd073 - [Clang-Tidy] New check `bugprone-redundant-branch-condition`

2020-08-31 Thread Adam Balogh via cfe-commits

Author: Adam Balogh
Date: 2020-08-31T16:00:59+02:00
New Revision: 14dd0737822ba476803320a2ff37a1012174d312

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

LOG: [Clang-Tidy] New check `bugprone-redundant-branch-condition`

Checking the same condition again in a nested `if` usually make no sense,
except if the value of the expression could have been changed between
the two checks. Although compilers may optimize this out, such code is
suspicious: the programmer may have meant to check something else.
Therefore it is worth to find such places in the code and notify the
user about the problem.

This patch implements a basic check for this problem. Currently it
only detects redundant conditions where the condition is a variable of
integral type. It also detects the possible bug if the variable is in an
//or// or //and// logical expression in the inner if and/or the variable
is in an //and// logical expression in the outer if statement. Negated
cases are not handled yet.

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

Added: 
clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.h

clang-tools-extra/docs/clang-tidy/checks/bugprone-redundant-branch-condition.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 3f735a8484d8..1556a2924f59 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -38,6 +38,7 @@
 #include "NotNullTerminatedResultCheck.h"
 #include "ParentVirtualCallCheck.h"
 #include "PosixReturnCheck.h"
+#include "RedundantBranchConditionCheck.h"
 #include "ReservedIdentifierCheck.h"
 #include "SignedCharMisuseCheck.h"
 #include "SizeofContainerCheck.h"
@@ -119,6 +120,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-move-forwarding-reference");
 CheckFactories.registerCheck(
 "bugprone-multiple-statement-macro");
+CheckFactories.registerCheck(
+"bugprone-redundant-branch-condition");
 CheckFactories.registerCheck(
 "bugprone-narrowing-conversions");
 CheckFactories.registerCheck("bugprone-no-escape");

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 6e7a94928a5a..169e0529d872 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -33,6 +33,7 @@ add_clang_library(clangTidyBugproneModule
   NotNullTerminatedResultCheck.cpp
   ParentVirtualCallCheck.cpp
   PosixReturnCheck.cpp
+  RedundantBranchConditionCheck.cpp
   ReservedIdentifierCheck.cpp
   SignedCharMisuseCheck.cpp
   SizeofContainerCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
new file mode 100644
index ..137356acbdba
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
@@ -0,0 +1,153 @@
+//===--- RedundantBranchConditionCheck.cpp - clang-tidy 
-===//
+//
+// 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 "RedundantBranchConditionCheck.h"
+#include "../utils/Aliasing.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+using clang::tidy::utils::hasPtrOrReferenceInFunc;
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+static const char CondVarStr[] = "cond_var";
+static const char OuterIfStr[] = "outer_if";
+static const char InnerIfStr[] = "inner_if";
+static const char FuncStr[] = "func";
+
+/// Returns whether `Var` is changed in `S` before `NextS`.
+static bool isChangedBefore(const Stmt *S, const Stmt *NextS,
+const VarDecl *Var, ASTContext *Context) {
+  ExprMutationAnalyzer MutAn(*S, *Context);
+  const auto  = Context->getSourceManager();
+  

[clang-tools-extra] f5fd748 - [clang-tidy] New check readability-prefer-member-initializer

2020-08-31 Thread Adam Balogh via cfe-commits

Author: Adam Balogh
Date: 2020-08-31T15:59:29+02:00
New Revision: f5fd7486d6c0debb465de3e927fcc31884874280

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

LOG: [clang-tidy] New check readability-prefer-member-initializer

Finds member initializations in the constructor body which can
be placed to the member initializers of the constructor instead.
This does not only improves the readability of the code but also
affects positively its performance. Class-member assignments
inside a control statement or following the first control
statement are ignored.

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

Added: 

clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.h

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-member-initializer.rst

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-modernize-use-default-member-init-assignment.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-modernize-use-default-member-init.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp

Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
index 39c2c552eb73..a9f5b3e0c15b 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
@@ -13,6 +13,7 @@ add_clang_library(clangTidyCppCoreGuidelinesModule
   NarrowingConversionsCheck.cpp
   NoMallocCheck.cpp
   OwningMemoryCheck.cpp
+  PreferMemberInitializerCheck.cpp
   ProBoundsArrayToPointerDecayCheck.cpp
   ProBoundsConstantArrayIndexCheck.cpp
   ProBoundsPointerArithmeticCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
index 4cb5022888d3..bf613109f0eb 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
@@ -22,6 +22,7 @@
 #include "NarrowingConversionsCheck.h"
 #include "NoMallocCheck.h"
 #include "OwningMemoryCheck.h"
+#include "PreferMemberInitializerCheck.h"
 #include "ProBoundsArrayToPointerDecayCheck.h"
 #include "ProBoundsConstantArrayIndexCheck.h"
 #include "ProBoundsPointerArithmeticCheck.h"
@@ -66,6 +67,8 @@ class CppCoreGuidelinesModule : public ClangTidyModule {
 "cppcoreguidelines-non-private-member-variables-in-classes");
 CheckFactories.registerCheck(
 "cppcoreguidelines-owning-memory");
+CheckFactories.registerCheck(
+"cppcoreguidelines-prefer-member-initializer");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-bounds-array-to-pointer-decay");
 CheckFactories.registerCheck(

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
new file mode 100644
index ..97ae586f9fdb
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
@@ -0,0 +1,233 @@
+//===--- PreferMemberInitializerCheck.cpp - clang-tidy ---===//
+//
+// 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 "PreferMemberInitializerCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace cppcoreguidelines {
+
+static bool isControlStatement(const Stmt *S) {
+  return isa(S) || isa(S) || isa(S) ||
+ isa(S) || isa(S) || isa(S) ||
+ isa(S) || isa(S) || isa(S);
+}
+
+static bool isNoReturnCallStatement(const Stmt *S) {
+  const auto *Call = dyn_cast(S);
+  if (!Call)
+return false;
+
+  const FunctionDecl *Func = Call->getDirectCallee();
+  if (!Func)
+return false;
+
+  return Func->isNoReturn();
+}
+
+static bool isLiteral(const Expr *E) {
+  return isa(E) || 

[PATCH] D81272: [clang-tidy] New check `bugprone-redundant-branch-condition`

2020-08-31 Thread Balogh , Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG14dd0737822b: [Clang-Tidy] New check 
`bugprone-redundant-branch-condition` (authored by baloghadamsoftware).

Changed prior to commit:
  https://reviews.llvm.org/D81272?vs=285656=288940#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81272

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-redundant-branch-condition.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
@@ -0,0 +1,1190 @@
+// RUN: %check_clang_tidy %s bugprone-redundant-branch-condition %t
+
+extern unsigned peopleInTheBuilding;
+extern unsigned fireFighters;
+
+bool isBurning();
+bool isReallyBurning();
+bool isCollapsing();
+void tryToExtinguish(bool&);
+void tryPutFireOut();
+bool callTheFD();
+void scream();
+
+bool someOtherCondition();
+
+//===--- Basic Positives --===//
+
+void positive_direct() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (onFire) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'onFire' [bugprone-redundant-branch-condition]
+  // CHECK-FIXES: {{^\ *$}}
+  scream();
+}
+// CHECK-FIXES: {{^\ *$}}
+  }
+}
+
+void positive_indirect() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (someOtherCondition()) {
+  if (onFire)
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant condition 'onFire' [bugprone-redundant-branch-condition]
+// CHECK-FIXES: {{^\ *$}}
+scream();
+}
+  }
+}
+
+void positive_direct_inner_and_lhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (onFire && peopleInTheBuilding > 0) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'onFire' [bugprone-redundant-branch-condition]
+  // CHECK-FIXES: if ( peopleInTheBuilding > 0) {
+  scream();
+}
+  }
+}
+
+void positive_indirect_inner_and_lhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (someOtherCondition()) {
+  if (onFire && peopleInTheBuilding > 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant condition 'onFire' [bugprone-redundant-branch-condition]
+// CHECK-FIXES: if ( peopleInTheBuilding > 0) {
+scream();
+  }
+}
+  }
+}
+
+void positive_direct_inner_and_rhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (peopleInTheBuilding > 0 && onFire) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'onFire' [bugprone-redundant-branch-condition]
+  // CHECK-FIXES: if (peopleInTheBuilding > 0 ) {
+  scream();
+}
+  }
+}
+
+void positive_indirect_inner_and_rhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (someOtherCondition()) {
+  if (peopleInTheBuilding > 0 && onFire) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant condition 'onFire' [bugprone-redundant-branch-condition]
+// CHECK-FIXES: if (peopleInTheBuilding > 0 ) {
+scream();
+  }
+}
+  }
+}
+
+void positive_direct_inner_or_lhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (onFire || isCollapsing()) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'onFire' [bugprone-redundant-branch-condition]
+  // CHECK-FIXES: {{^\ *$}}
+  scream();
+}
+// CHECK-FIXES: {{^\ *$}}
+  }
+}
+
+void positive_indirect_inner_or_lhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (someOtherCondition()) {
+  if (onFire || isCollapsing()) {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant condition 'onFire' [bugprone-redundant-branch-condition]
+// CHECK-FIXES: {{^\ *$}}
+scream();
+  }
+  // CHECK-FIXES: {{^\ *$}}
+}
+  }
+}
+
+void positive_direct_inner_or_rhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (isCollapsing() || onFire) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'onFire' [bugprone-redundant-branch-condition]
+  // CHECK-FIXES: {{^\ *$}}
+  scream();
+}
+// CHECK-FIXES: {{^\ *$}}
+  }
+}
+
+void positive_indirect_inner_or_rhs() {
+  bool onFire = isBurning();
+  if (onFire) {
+if (someOtherCondition()) {
+  if (isCollapsing() || onFire) {
+// CHECK-MESSAGES: 

[PATCH] D71199: [clang-tidy] New check cppcoreguidelines-prefer-member-initializer

2020-08-31 Thread Balogh , Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf5fd7486d6c0: [clang-tidy] New check 
readability-prefer-member-initializer (authored by baloghadamsoftware).

Changed prior to commit:
  https://reviews.llvm.org/D71199?vs=285657=288939#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71199

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-member-initializer.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-modernize-use-default-member-init-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-modernize-use-default-member-init.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
@@ -0,0 +1,454 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-prefer-member-initializer %t
+
+class Simple1 {
+  int n;
+  double x;
+
+public:
+  Simple1() {
+// CHECK-FIXES: Simple1() : n(0), x(0.0) {
+n = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+x = 0.0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple1(int nn, double xx) {
+// CHECK-FIXES: Simple1(int nn, double xx) : n(nn), x(xx) {
+n = nn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+x = xx;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple1() = default;
+};
+
+class Simple2 {
+  int n;
+  double x;
+
+public:
+  Simple2() : n(0) {
+// CHECK-FIXES: Simple2() : n(0), x(0.0) {
+x = 0.0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple2(int nn, double xx) : n(nn) {
+// CHECK-FIXES: Simple2(int nn, double xx) : n(nn), x(xx) {
+x = xx;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple2() = default;
+};
+
+class Simple3 {
+  int n;
+  double x;
+
+public:
+  Simple3() : x(0.0) {
+// CHECK-FIXES: Simple3() : n(0), x(0.0) {
+n = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple3(int nn, double xx) : x(xx) {
+// CHECK-FIXES: Simple3(int nn, double xx) : n(nn), x(xx) {
+n = nn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple3() = default;
+};
+
+int something_int();
+double something_double();
+
+class Simple4 {
+  int n;
+
+public:
+  Simple4() {
+// CHECK-FIXES: Simple4() : n(something_int()) {
+n = something_int();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple4() = default;
+};
+
+static bool dice();
+
+class Complex1 {
+  int n;
+  int m;
+
+public:
+  Complex1() : n(0) {
+if (dice())
+  m = 1;
+// NO-MESSAGES: initialization of 'm' is nested in a conditional expression
+  }
+
+  ~Complex1() = default;
+};
+
+class Complex2 {
+  int n;
+  int m;
+
+public:
+  Complex2() : n(0) {
+if (!dice())
+  return;
+m = 1;
+// NO-MESSAGES: initialization of 'm' follows a conditional expression
+  }
+
+  

[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-08-31 Thread Steve Canon via Phabricator via cfe-commits
scanon added inline comments.



Comment at: compiler-rt/lib/builtins/fp_div_impl.inc:99
+  //   0 < x0(b) < 1
+  //   abs(x0(b) - 1/b) <= 3/4 - 1/sqrt(2)
+

sepavloff wrote:
> atrosinenko wrote:
> > sepavloff wrote:
> > > This estimation is absent from the original comment. Do you have 
> > > reference where it came from? Also the original comment states `This is 
> > > accurate to about 3.5 binary digits`. Is still true? If yes, it could be 
> > > worth copying here.
> > This approximation was deduced by writing down the derivative of `f ` "in 
> > infinite precision" and finding its root. Then the values of `f` applied to 
> > its root, 1.0 and 2.0 were calculated -- as far as I remember, **all of 
> > them** were `3/4 - 1/sqrt(2)` or negated - //this is what "minimax 
> > polynomial" probably means, that term was just copied from the original 
> > implementation :)//.
> IIUC, you don't want to put this statement here because you are us not sure 
> it is true? Sounds reasonable.
To be precise, what _minimax polynomial_ means is that p(x) = 3/4 + 1/sqrt(2) - 
x/2 is the first-order polynomial that minimizes the error term max(|1/x - 
p(x)|) on the interval [1,2]. I.e. every other linear polynomial would achieve 
a larger maximum error.

The bound of a minimax approximation to a well-behaved function is always 
achieved at the endpoints, so we can just evaluate at 1 to get the max error: 
|1/1 - 3/4 - 1/sqrt(2) + 1/2| = 3/4 - 1/sqrt(2) = 0.04289... (which is actually 
about _4.5_ bits).



Comment at: compiler-rt/lib/builtins/fp_div_impl.inc:101-102
+
+  // Then, refine the reciprocal estimate using a Newton-Raphson iteration:
+  // x_{n+1} = x_n * (2 - x_n * b)
+  // Let e_n := x_n - 1/b_hw

atrosinenko wrote:
> sepavloff wrote:
> > The original comment states:
> > ```
> >   // This doubles the number of correct binary digits in the approximation
> >   // with each iteration.
> > ```
> > It is true in this implementation? If yes, it could be worth copying here.
> For me this looks too vague. This is probably //approximately true// but I 
> don't know how exactly this should be interpreted.
N-R is quadratically convergent under a bunch of assumptions on how good the 
initial guess is and bounds on the second derivative, which are all satisfied 
here, but probably not worth going into in the comments. IIRC the usual 
reference here is Montuschi and Mezzalama's "Survey of square rooting 
algorithms" (1990).



Comment at: compiler-rt/lib/builtins/fp_div_impl.inc:109
+
+#if NUMBER_OF_HALF_ITERATIONS > 0
+  // Starting with (n-1) half-width iterations

sepavloff wrote:
> atrosinenko wrote:
> > sepavloff wrote:
> > > It is good optimization. Could you please put a comment shortly 
> > > describing the idea of using half-sized temporaries?
> > The idea is just "I guess this takes less CPU time and I have managed to 
> > prove error bounds for it". :) Specifically, for float128, the rep_t * 
> > rep_t multiplication will be emulated with lots of CPU instructions while 
> > the lower half contain some noise at that point. This particular 
> > optimization did exist in the original implementation for float64 and 
> > float128. For float32 it had not much sense, I guess. Still, estimations 
> > were calculated for the case of float32 with half-size iterations as it may 
> > be useful for MSP430 and other 16-bit targets.
> The idea is clear but it require some study of the sources. I would propose 
> to add a comment saying:
> ```
> At the first iterations number of significant digits is small, so we may use 
> shorter type values. Operations on them are usually faster.
> ```
> or something like that.
This is absolutely standard in HW construction of pipelined iterative dividers 
and square root units, so I'm not sure how much explanation is really needed =)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85031

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


[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

2020-08-31 Thread Douglas Chen via Phabricator via cfe-commits
dougpuob updated this revision to Diff 288938.
dougpuob added a comment.

Improved suggestions of code review.

1. Moved release notes to right place. [Eugene.Zelenko]
2. Added new casting types to doc(readability-identifier-naming.rst) 
[Eugene.Zelenko]
3. Moved partial code to a new function, 
IdentifierNamingCheck::getDeclTypeName(). [njames93]


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D86671

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation.cpp
@@ -0,0 +1,120 @@
+#include 
+#include 
+
+// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
+// RUN:   -config="{CheckOptions: [\
+// RUN:   {key: readability-identifier-naming.VariableCase, value: szHungarianNotation}, \
+// RUN:   ]}"
+
+class UnlistedClass {};
+UnlistedClass Unlisted1;
+// CHECK-NOT: :[[@LINE-2]]
+
+UnlistedClass cUnlisted2;
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for variable 'cUnlisted2' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}UnlistedClass Unlisted2;
+
+UnlistedClass objUnlistedClass3;
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for variable 'objUnlistedClass3' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}UnlistedClass UnlistedClass3;
+
+typedef int INDEX;
+INDEX iIndex = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for variable 'iIndex' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}INDEX Index = 0;
+
+const char *NamePtr = "Name";
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for variable 'NamePtr' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}const char *szNamePtr = "Name";
+
+const char NameArray[] = "Name";
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for variable 'NameArray' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}const char szNameArray[] = "Name";
+
+void *BufferPtr1 = NULL;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for variable 'BufferPtr1' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}void *pBufferPtr1 = NULL;
+
+void **BufferPtr2 = NULL;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for variable 'BufferPtr2' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}void **ppBufferPtr2 = NULL;
+
+void **pBufferPtr3 = NULL;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for variable 'pBufferPtr3' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}void **ppBufferPtr3 = NULL;
+
+int8_t ValueI8 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for variable 'ValueI8' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}int8_t i8ValueI8 = 0;
+
+int16_t ValueI16 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for variable 'ValueI16' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}int16_t i16ValueI16 = 0;
+
+int32_t ValueI32 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for variable 'ValueI32' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}int32_t i32ValueI32 = 0;
+
+int64_t ValueI64 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for variable 'ValueI64' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}int64_t i64ValueI64 = 0;
+
+uint8_t ValueU8 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for variable 'ValueU8' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}uint8_t u8ValueU8 = 0;
+
+uint16_t ValueU16 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for variable 'ValueU16' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}uint16_t u16ValueU16 = 0;
+
+uint32_t ValueU32 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for variable 'ValueU32' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}uint32_t u32ValueU32 = 0;
+
+uint64_t ValueU64 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for variable 'ValueU64' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}uint64_t u64ValueU64 = 0;
+
+float ValueFloat = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for variable 'ValueFloat' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}float fValueFloat = 0;
+
+double ValueDouble = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for variable 'ValueDouble' [readability-identifier-naming]
+// 

[PATCH] D84603: Thread safety analysis: More consistent warning message

2020-08-31 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 a suggestion for a comment, thank you!




Comment at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:205
 
+  /// Warn when calling a function that the negative capability is not held.
+  /// \param D -- The decl for the function requiring the negative capability.

aaronpuchert wrote:
> Should probably be "**a** negative capability", silly copy-and-paste error.
`Warn when calling a function and a negative capability is not held.`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84603

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


[PATCH] D85032: [builtins] Make divXf3 handle denormal results

2020-08-31 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 288935.
atrosinenko added a comment.

Re-upload after amending parent diff + add minor clarification.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85032

Files:
  compiler-rt/lib/builtins/fp_div_impl.inc
  compiler-rt/test/builtins/Unit/divdf3_test.c
  compiler-rt/test/builtins/Unit/divsf3_test.c
  compiler-rt/test/builtins/Unit/divtf3_test.c

Index: compiler-rt/test/builtins/Unit/divtf3_test.c
===
--- compiler-rt/test/builtins/Unit/divtf3_test.c
+++ compiler-rt/test/builtins/Unit/divtf3_test.c
@@ -146,6 +146,13 @@
  UINT64_C(0xfffe)))
 return 1;
 
+// smallest normal value divided by 2.0
+if (test__divtf3(0x1.0p-16382L, 2.L, UINT64_C(0x8000), UINT64_C(0x0)))
+  return 1;
+// smallest subnormal result
+if (test__divtf3(0x1.0p-1022L, 0x1p+52L, UINT64_C(0x0), UINT64_C(0x1)))
+  return 1;
+
 // any / any
 if (test__divtf3(0x1.a23b45362464523375893ab4cdefp+5L,
  0x1.eedcbaba3a94546558237654321fp-1L,
Index: compiler-rt/test/builtins/Unit/divsf3_test.c
===
--- compiler-rt/test/builtins/Unit/divsf3_test.c
+++ compiler-rt/test/builtins/Unit/divsf3_test.c
@@ -92,5 +92,20 @@
 if (test__divsf3(0x1.0p+0F, 0x1.0001p+0F, UINT32_C(0x3f7fff00)))
   return 1;
 
+// smallest normal value divided by 2.0
+if (test__divsf3(0x1.0p-126F, 2.0F, UINT32_C(0x0040)))
+  return 1;
+// smallest subnormal result
+if (test__divsf3(0x1.0p-126F, 0x1p+23F, UINT32_C(0x0001)))
+  return 1;
+
+// some misc test cases obtained by fuzzing against h/w implementation
+if (test__divsf3(-0x1.3e75e6p-108F, -0x1.cf372p+38F, UINT32_C(0x0006)))
+  return 1;
+if (test__divsf3(0x1.e77c54p+81F, -0x1.e77c52p-47F, UINT32_C(0xff80)))
+  return 1;
+if (test__divsf3(0x1.fep-126F, 2.F, UINT32_C(0x0080)))
+  return 1;
+
 return 0;
 }
Index: compiler-rt/test/builtins/Unit/divdf3_test.c
===
--- compiler-rt/test/builtins/Unit/divdf3_test.c
+++ compiler-rt/test/builtins/Unit/divdf3_test.c
@@ -92,6 +92,13 @@
 if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;
 
+// smallest normal value divided by 2.0
+if (test__divdf3(0x1.0p-1022, 2., UINT64_C(0x0008)))
+  return 1;
+// smallest subnormal result
+if (test__divdf3(0x1.0p-1022, 0x1.0p+52, UINT64_C(0x0001)))
+  return 1;
+
 // some misc test cases obtained by fuzzing against h/w implementation
 if (test__divdf3(0x1.fdc239dd64735p-658, -0x1.fff9364c0843fp-948, UINT64_C(0xd20fdc8fc0ceffb1)))
   return 1;
@@ -99,6 +106,12 @@
   return 1;
 if (test__divdf3(-0x1.da7dfe6048b8bp-875, 0x1.ffc7ea3ff60a4p-610, UINT64_C(0xaf5dab1fe0269e2a)))
   return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.9p+5, UINT64_C(0x51eb851eb852)))
+  return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.0028p+41, UINT64_C(0x07ff)))
+  return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.0028p+52, UINT64_C(0x1)))
+  return 1;
 
 return 0;
 }
Index: compiler-rt/lib/builtins/fp_div_impl.inc
===
--- compiler-rt/lib/builtins/fp_div_impl.inc
+++ compiler-rt/lib/builtins/fp_div_impl.inc
@@ -347,12 +347,17 @@
 // effectively doubling its value as well as its error estimation.
 residualLo = (aSignificand << (significandBits + 1)) - quotient_UQ1 * bSignificand;
 writtenExponent -= 1;
+aSignificand <<= 1;
   } else {
 // Highest bit is 1 (the UQ1.(SB+1) value is in [1, 2)), convert it
 // to UQ1.SB by right shifting by 1. Least significant bit is omitted.
 quotient_UQ1 >>= 1;
 residualLo = (aSignificand << significandBits) - quotient_UQ1 * bSignificand;
   }
+  // NB: residualLo is calculated above for the normal result case.
+  // It is re-computed on denormal path that is expected to be not so
+  // performance-sensitive.
+
   // Now, q cannot be greater than a/b and can differ by at most 8*P * 2^-W + 2^-SB
   // Each NextAfter() increments the floating point value by at least 2^-SB
   // (more, if exponent was incremented).
@@ -380,19 +385,25 @@
   // Now, quotient_UQ1_SB <= the correctly-rounded result
   // and may need taking NextAfter() up to 3 times (see error estimates above)
   // r = a - b * q
+  rep_t absResult;
+  if (writtenExponent > 0) {
+// Clear the implicit bit
+absResult = quotient_UQ1 & significandMask;
+// Insert the exponent
+absResult |= (rep_t)writtenExponent << significandBits;
+residualLo <<= 1;
+  } else {
+// Prevent shift amount from being negative
+if 

[PATCH] D86841: [clang] Add noprogress attribute deduction for infinite loops

2020-08-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/CodeGen/CGLoopInfo.h:211
 llvm::ArrayRef Attrs, const llvm::DebugLoc ,
-const llvm::DebugLoc );
+const llvm::DebugLoc , const bool NoProgress = false);
 

I'd drop the top-level `const` on the declaration of `NoProgress` (that's not a 
style we typically use in the project).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86841

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


[PATCH] D33825: [clang-tidy] signal handler must be plain old function check

2020-08-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D33825#2246369 , @jfb wrote:

> MSC54-CPP refers to POF, which as I pointed out above isn't relevant anymore. 
> I'd much rather have a diagnostic which honors the state of things after 
> http://wg21.link/p0270.

I agree, and I've commented on that rule to remind the folks at CERT that the 
rule has largely gone stale.

> Additionally, lots of what MSC54-CPP intends is implementation-defined. We 
> shouldn't diagnose for things that clang has defined as signal safe, at least 
> not by default.

Also agreed.




Comment at: 
clang-tools-extra/clang-tidy/cert/SignalHandlerMustBePlainOldFunctionCheck.cpp:42
+
+const char *cxxStmtText(const Stmt *stmt) {
+  if (llvm::isa(stmt))

I'm not super keen on this approach because as new C++ constructs are added, 
this will continually need to be updated, which is a maintenance burden I think 
we should try to avoid. I would rather use some generic wording or tie the 
wording automatically to something provided by the `Stmt` class.



Comment at: 
clang-tools-extra/clang-tidy/cert/SignalHandlerMustBePlainOldFunctionCheck.cpp:44
+  if (llvm::isa(stmt))
+return "Binding temporary C++ expression here";
+  else if (llvm::isa(stmt))

Diagnostics in clang-tidy should start with a lowercase letter



Comment at: 
clang-tools-extra/clang-tidy/cert/SignalHandlerMustBePlainOldFunctionCheck.cpp:91
+const char *cxxDeclText(const Decl *decl) {
+  if (llvm::isa(decl))
+return "Constructor declared here";

Similar concerns here.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D33825

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


[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-08-31 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 288932.
atrosinenko added a comment.

Clarify rounding-related part of function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85031

Files:
  compiler-rt/lib/builtins/divdf3.c
  compiler-rt/lib/builtins/divsf3.c
  compiler-rt/lib/builtins/divtf3.c
  compiler-rt/lib/builtins/fp_div_impl.inc
  compiler-rt/lib/builtins/fp_lib.h
  compiler-rt/lib/builtins/int_util.h
  compiler-rt/test/builtins/Unit/divdf3_test.c

Index: compiler-rt/test/builtins/Unit/divdf3_test.c
===
--- compiler-rt/test/builtins/Unit/divdf3_test.c
+++ compiler-rt/test/builtins/Unit/divdf3_test.c
@@ -92,5 +92,13 @@
 if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;
 
+// some misc test cases obtained by fuzzing against h/w implementation
+if (test__divdf3(0x1.fdc239dd64735p-658, -0x1.fff9364c0843fp-948, UINT64_C(0xd20fdc8fc0ceffb1)))
+  return 1;
+if (test__divdf3(-0x1.78abb261d47c8p+794, 0x1.fb01d537cc5aep+266, UINT64_C(0xe0e7c6148ffc23e3)))
+  return 1;
+if (test__divdf3(-0x1.da7dfe6048b8bp-875, 0x1.ffc7ea3ff60a4p-610, UINT64_C(0xaf5dab1fe0269e2a)))
+  return 1;
+
 return 0;
 }
Index: compiler-rt/lib/builtins/int_util.h
===
--- compiler-rt/lib/builtins/int_util.h
+++ compiler-rt/lib/builtins/int_util.h
@@ -28,4 +28,20 @@
 #define COMPILE_TIME_ASSERT2(expr, cnt)\
   typedef char ct_assert_##cnt[(expr) ? 1 : -1] UNUSED
 
+// Force unrolling the code specified to be repeated N times.
+#define REPEAT_0_TIMES(code_to_repeat) /* do nothing */
+#define REPEAT_1_TIMES(code_to_repeat) code_to_repeat
+#define REPEAT_2_TIMES(code_to_repeat) \
+  REPEAT_1_TIMES(code_to_repeat)   \
+  code_to_repeat
+#define REPEAT_3_TIMES(code_to_repeat) \
+  REPEAT_2_TIMES(code_to_repeat)   \
+  code_to_repeat
+#define REPEAT_4_TIMES(code_to_repeat) \
+  REPEAT_3_TIMES(code_to_repeat)   \
+  code_to_repeat
+
+#define REPEAT_N_TIMES_(N, code_to_repeat) REPEAT_##N##_TIMES(code_to_repeat)
+#define REPEAT_N_TIMES(N, code_to_repeat) REPEAT_N_TIMES_(N, code_to_repeat)
+
 #endif // INT_UTIL_H
Index: compiler-rt/lib/builtins/fp_lib.h
===
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -40,9 +40,12 @@
 
 #if defined SINGLE_PRECISION
 
+typedef uint16_t half_rep_t;
 typedef uint32_t rep_t;
+typedef uint64_t twice_rep_t;
 typedef int32_t srep_t;
 typedef float fp_t;
+#define HALF_REP_C UINT16_C
 #define REP_C UINT32_C
 #define significandBits 23
 
@@ -58,9 +61,11 @@
 
 #elif defined DOUBLE_PRECISION
 
+typedef uint32_t half_rep_t;
 typedef uint64_t rep_t;
 typedef int64_t srep_t;
 typedef double fp_t;
+#define HALF_REP_C UINT32_C
 #define REP_C UINT64_C
 #define significandBits 52
 
@@ -102,9 +107,11 @@
 #elif defined QUAD_PRECISION
 #if __LDBL_MANT_DIG__ == 113 && defined(__SIZEOF_INT128__)
 #define CRT_LDBL_128BIT
+typedef uint64_t half_rep_t;
 typedef __uint128_t rep_t;
 typedef __int128_t srep_t;
 typedef long double fp_t;
+#define HALF_REP_C UINT64_C
 #define REP_C (__uint128_t)
 // Note: Since there is no explicit way to tell compiler the constant is a
 // 128-bit integer, we let the constant be casted to 128-bit integer
Index: compiler-rt/lib/builtins/fp_div_impl.inc
===
--- /dev/null
+++ compiler-rt/lib/builtins/fp_div_impl.inc
@@ -0,0 +1,413 @@
+//===-- fp_div_impl.inc - Floating point division -*- 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
+//
+//===--===//
+//
+// This file implements soft-float division with the IEEE-754 default
+// rounding (to nearest, ties to even).
+//
+//===--===//
+
+#include "fp_lib.h"
+
+// The __divXf3__ function implements Newton-Raphson floating point division.
+// It uses 3 iterations for float32, 4 for float64 and 5 for float128,
+// respectively. Due to number of significant bits being roughly doubled
+// every iteration, the two modes are supported: N full-width iterations (as
+// it is done for float32 by default) and (N-1) half-width iteration plus one
+// final full-width iteration. It is expected that half-width integer
+// operations 

[PATCH] D85984: [analyzer] Add a new checker alpha.cplusplus.CPlusPlus11Lock

2020-08-31 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 288930.
ASDenysPetrov added a comment.

Added //shared// semantics checks and correspondent tests.


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

https://reviews.llvm.org/D85984

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
  clang/test/Analysis/Checkers/CPlusPlus11LockChecker.cpp

Index: clang/test/Analysis/Checkers/CPlusPlus11LockChecker.cpp
===
--- /dev/null
+++ clang/test/Analysis/Checkers/CPlusPlus11LockChecker.cpp
@@ -0,0 +1,902 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.CPlusPlus11Lock -verify %s
+
+namespace std {
+
+struct mutex {
+  void lock();
+  bool try_lock();
+  void unlock();
+};
+
+struct timed_mutex {
+  void lock();
+  bool try_lock();
+  void unlock();
+};
+
+struct recursive_mutex {
+  void lock();
+  bool try_lock();
+  void unlock();
+};
+
+struct recursive_timed_mutex {
+  void lock();
+  bool try_lock();
+  void unlock();
+};
+
+struct shared_mutex {
+  void lock();
+  bool try_lock();
+  void unlock();
+  void lock_shared();
+  bool try_lock_shared();
+  void unlock_shared();
+};
+
+struct shared_timed_mutex {
+  void lock();
+  bool try_lock();
+  void unlock();
+  void lock_shared();
+  bool try_lock_shared();
+  void unlock_shared();
+};
+
+template 
+struct lock_guard {
+  T 
+  lock_guard(T ) : t(m) {
+t.lock();
+  }
+  ~lock_guard() {
+t.unlock();
+  }
+};
+
+template 
+struct shared_lock {
+  T 
+  shared_lock(T ) : t(m) {
+t.lock_shared();
+  }
+  ~shared_lock() {
+t.unlock_shared();
+  }
+};
+} // namespace std
+
+std::mutex m1;
+std::mutex m2;
+
+// mutex ok
+
+void m_ok1() {
+  m1.lock(); // no-warning
+}
+
+void m_ok2() {
+  m1.unlock(); // no-warning
+}
+
+void m_ok3() {
+  m1.lock();   // no-warning
+  m1.unlock(); // no-warning
+}
+
+void m_ok4() {
+  m1.lock();   // no-warning
+  m1.unlock(); // no-warning
+  m1.lock();   // no-warning
+  m1.unlock(); // no-warning
+}
+
+void m_ok5() {
+  m1.lock();   // no-warning
+  m1.unlock(); // no-warning
+  m2.lock();   // no-warning
+  m2.unlock(); // no-warning
+}
+
+void m_ok6(void) {
+  m1.lock();   // no-warning
+  m2.lock();   // no-warning
+  m2.unlock(); // no-warning
+  m1.unlock(); // no-warning
+}
+
+void m_ok7(void) {
+  if (m1.try_lock()) // no-warning
+m1.unlock(); // no-warning
+}
+
+void m_ok8(void) {
+  m1.unlock();   // no-warning
+  if (m1.try_lock()) // no-warning
+m1.unlock(); // no-warning
+}
+
+void m_ok9(void) {
+  if (!m1.try_lock()) // no-warning
+m1.lock();// no-warning
+  m1.unlock();// no-warning
+}
+
+void m_ok10() {
+  std::lock_guard gl(m1); // no-warning
+}
+
+// mutex bad
+
+void m_bad1() {
+  m1.lock(); // no-warning
+  m1.lock(); // expected-warning{{This lock has already been acquired}}
+}
+
+void m_bad2() {
+  m1.lock();   // no-warning
+  m1.unlock(); // no-warning
+  m1.unlock(); // expected-warning {{This lock has already been unlocked}}
+}
+
+void m_bad3() {
+  m1.lock();   // no-warning
+  m2.lock();   // no-warning
+  m1.unlock(); // expected-warning {{This was not the most recently acquired lock. Possible lock order reversal}}
+  m2.unlock(); // no-warning
+}
+
+void m_bad5() {
+  while (true)
+m1.unlock(); // expected-warning {{This lock has already been unlocked}}
+}
+
+void m_bad6() {
+  while (true)
+m1.lock(); // expected-warning{{This lock has already been acquired}}
+}
+
+void m_bad7() {
+  if (m1.try_lock()) // no-warning
+m1.lock();   // expected-warning{{This lock has already been acquired}}
+}
+
+std::timed_mutex tm1;
+std::timed_mutex tm2;
+
+// timed_mutex ok
+
+void tm_ok1() {
+  tm1.lock(); // no-warning
+}
+
+void tm_ok2() {
+  tm1.unlock(); // no-warning
+}
+
+void tm_ok3() {
+  tm1.lock();   // no-warning
+  tm1.unlock(); // no-warning
+}
+
+void tm_ok4() {
+  tm1.lock();   // no-warning
+  tm1.unlock(); // no-warning
+  tm1.lock();   // no-warning
+  tm1.unlock(); // no-warning
+}
+
+void tm_ok5() {
+  tm1.lock();   // no-warning
+  tm1.unlock(); // no-warning
+  tm2.lock();   // no-warning
+  tm2.unlock(); // no-warning
+}
+
+void tm_ok6(void) {
+  tm1.lock();   // no-warning
+  tm2.lock();   // no-warning
+  tm2.unlock(); // no-warning
+  tm1.unlock(); // no-warning
+}
+
+void tm_ok7(void) {
+  if (tm1.try_lock()) // no-warning
+tm1.unlock(); // no-warning
+}
+
+void tm_ok8(void) {
+  tm1.unlock();   // no-warning
+  if (tm1.try_lock()) // no-warning
+tm1.unlock(); // no-warning
+}
+
+void tm_ok9(void) {
+  if (!tm1.try_lock()) // no-warning
+tm1.lock();// no-warning
+  tm1.unlock();// no-warning
+}
+
+void tm_ok10() {
+  std::lock_guard gl(tm1); // no-warning
+}
+
+// timed_mutex bad
+
+void tm_bad1() {
+  tm1.lock(); // no-warning
+  tm1.lock(); // expected-warning{{This lock has already been acquired}}
+}
+
+void 

[PATCH] D86820: [X86] Add a /tune: option for clang-cl

2020-08-31 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Would it be enough for users to specify /clang:-mtune instead? How does icc 
spell its option?


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

https://reviews.llvm.org/D86820

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


[PATCH] D86736: [analyzer][NFC] Don't bind values to ObjCForCollectionStmt, replace it with a GDM trait

2020-08-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal resigned from this revision.
steakhal added a comment.
Herald added a subscriber: steakhal.

I don't have much to say, but to keep up the good work xD
I will follow this and the rest of your patches @Szelethus.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86736

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


[PATCH] D86369: [Sema][MSVC] warn at dynamic_cast when /GR- is given

2020-08-31 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: clang/lib/Sema/SemaCast.cpp:895
+  if (!Self.getLangOpts().RTTIData) {
+bool isMSVC = Self.getDiagnostics().getDiagnosticOptions().getFormat() ==
+  DiagnosticOptions::MSVC;

zequanwu wrote:
> hans wrote:
> > zequanwu wrote:
> > > hans wrote:
> > > > I'm not sure isMSVC is the best name (it's not clear what aspect is 
> > > > MSVC exactly -- in this case it's the diagnostics format).
> > > > 
> > > > It's possible to target MSVC both with clang-cl and with regular clang.
> > > > 
> > > > For example, one could use
> > > > 
> > > >   clang-cl /c /tmp/a.cpp
> > > > 
> > > > or
> > > > 
> > > >   clang -c /tmp/a.cpp -target i686-pc-windows-msvc19.11.0 
> > > > -fms-extensions
> > > > 
> > > > 
> > > > My understanding is that the purpose of "isMSVC" here is to try and 
> > > > detect if we're using clang-cl or clang so that the diagnostic can say 
> > > > "/GR-" or "-fno-rtti-data". So maybe it's better to call it "isClangCL" 
> > > > or something like that.
> > > > 
> > > > Also, I don't think we should check "isMSVC" in the if-statement below. 
> > > > We want the warning to fire both when using clang and clang-cl: as long 
> > > > as -fno-rtti-data or /GR- is used, the warning makes sense.
> > > > 
> > > > So I think the code could be more like:
> > > > 
> > > > ```
> > > > if (!Self.getLangOpts().RTTIData && !DestPointee->isVoidType()) {
> > > >   bool isClangCL = ...;
> > > >   Self.Diag(...) << isClangCL;
> > > > }
> > > > ```
> > > MSVC will warn even if the DestPointee is void type. What I thought is if 
> > > invoked by clang-cl warn regardless of DeskPointee type. If invoked by 
> > > clang, warn if it's not void type. 
> > > https://godbolt.org/z/475q5v. I noticed MSVC won't warn at typeid if /GR- 
> > > is given. Probably I should remove the warning in typeid.
> > If it's true the casting to void* doesn't need RTTI data (I think it is, 
> > but would be good to verify), then it doesn't make sense to warn. We don't 
> > have to follow MSVC's behavior when it doesn't make sense :)
> > 
> > Similar reasoning for typeid() - I assume it won't work with /GR- also with 
> > MSVC, so warning about it probably makes sense.
> In clang, I believe that dynamic_cast to void* doesn't use RTTI data: 
> https://godbolt.org/z/Kbr7Mq
> Looks like MSVC only warns if the operand of typeid is not pointer: 
> https://godbolt.org/z/chcMcn
> 
When targeting Windows, dynamic_cast to void* is implemented with in a runtime 
function, RTCastToVoid: https://godbolt.org/z/Kecr7z
I wonder if that uses RTTI data internally though...

For typeid() I guess it would also warn on references? Maybe we should do the 
same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86369

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


[PATCH] D86373: [analyzer] Add modeling for unique_ptr move constructor

2020-08-31 Thread Nithin VR via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1b743a9efa08: [analyzer] Add modeling for unique_ptr move 
constructor (authored by vrnithinkumar).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86373

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/smart-ptr-text-output.cpp
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -17,7 +17,8 @@
   if (P)
 clang_analyzer_warnIfReached(); // no-warning
   // TODO: Report a null dereference (instead).
-  *P.get() = 1; // expected-warning {{Method called on moved-from object 'P'}}
+  *P.get() = 1; // expected-warning {{Method called on moved-from object 'P' [cplusplus.Move]}}
+  // expected-warning@-1 {{Dereference of null pointer [core.NullDereference]}}
 }
 
 // Don't crash when attempting to model a call with unknown callee.
@@ -333,3 +334,44 @@
   P = returnRValRefOfUniquePtr();
   P->foo(); // No warning. 
 }
+
+void derefMoveConstructedWithValidPtr() {
+  std::unique_ptr PToMove(new A());
+  std::unique_ptr P(std::move(PToMove));
+  P->foo(); // No warning.
+}
+
+void derefMoveConstructedWithNullPtr() {
+  std::unique_ptr PToMove;
+  std::unique_ptr P(std::move(PToMove));
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefMoveConstructedWithUnknownPtr(std::unique_ptr PToMove) {
+  std::unique_ptr P(std::move(PToMove));
+  P->foo(); // No warning.
+}
+
+void derefValidPtrMovedToConstruct() {
+  std::unique_ptr PToMove(new A());
+  std::unique_ptr P(std::move(PToMove));
+  PToMove->foo(); // expected-warning {{Dereference of null smart pointer 'PToMove' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefNullPtrMovedToConstruct() {
+  std::unique_ptr PToMove;
+  std::unique_ptr P(std::move(PToMove));
+  PToMove->foo(); // expected-warning {{Dereference of null smart pointer 'PToMove' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefUnknownPtrMovedToConstruct(std::unique_ptr PToMove) {
+  std::unique_ptr P(std::move(PToMove));
+  PToMove->foo(); // expected-warning {{Dereference of null smart pointer 'PToMove' [alpha.cplusplus.SmartPtr]}}
+}
+
+std::unique_ptr &();
+
+void derefMoveConstructedWithRValueRefReturn() {
+  std::unique_ptr P(functionReturnsRValueRef());
+  P->foo();  // No warning.
+}
Index: clang/test/Analysis/smart-ptr-text-output.cpp
===
--- clang/test/Analysis/smart-ptr-text-output.cpp
+++ clang/test/Analysis/smart-ptr-text-output.cpp
@@ -144,7 +144,7 @@
   std::unique_ptr P(new A()); // expected-note {{Smart pointer 'P' is constructed}}
   // FIXME: above note should go away once we fix marking region not interested. 
   std::unique_ptr PToMove; // expected-note {{Default constructed smart pointer 'PToMove' is null}}
-  P = std::move(PToMove); // expected-note {{Null pointer value move-assigned to 'P'}}
+  P = std::move(PToMove); // expected-note {{A null pointer value is moved to 'P'}}
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
   // expected-note@-1 {{Dereference of null smart pointer 'P'}}
 }
@@ -170,3 +170,32 @@
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
   // expected-note@-1 {{Dereference of null smart pointer 'P'}}
 }
+
+void derefMoveConstructedWithNullPtr() {
+  std::unique_ptr PToMove; // expected-note {{Default constructed smart pointer 'PToMove' is null}}
+  std::unique_ptr P(std::move(PToMove)); // expected-note {{A null pointer value is moved to 'P'}}
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+  // expected-note@-1{{Dereference of null smart pointer 'P'}}
+}
+
+void derefValidPtrMovedToConstruct() {
+  std::unique_ptr PToMove(new A()); // expected-note {{Smart pointer 'PToMove' is constructed}}
+  // FIXME: above note should go away once we fix marking region not interested. 
+  std::unique_ptr P(std::move(PToMove)); // expected-note {{Smart pointer 'PToMove' is null after being moved to 'P'}}
+  PToMove->foo(); // expected-warning {{Dereference of null smart pointer 'PToMove' [alpha.cplusplus.SmartPtr]}}
+  // expected-note@-1{{Dereference of null smart pointer 'PToMove'}}
+}
+
+void derefNullPtrMovedToConstruct() {
+  std::unique_ptr PToMove; // expected-note {{Default constructed smart pointer 'PToMove' is null}}
+  // FIXME: above note should go away once we fix marking region not interested. 
+  std::unique_ptr P(std::move(PToMove)); // expected-note {{Smart pointer 'PToMove' is null after being moved to 'P'}}
+  PToMove->foo(); // expected-warning {{Dereference of null smart pointer 'PToMove' 

[clang] 1b743a9 - [analyzer] Add modeling for unique_ptr move constructor

2020-08-31 Thread Nithin Vadukkumchery Rajendrakumar via cfe-commits

Author: Nithin Vadukkumchery Rajendrakumar
Date: 2020-08-31T14:36:11+02:00
New Revision: 1b743a9efa0884ed3a48ebea97b6ef6cb7d73164

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

LOG: [analyzer] Add modeling for unique_ptr move constructor

Summary:
Add support for handling move contructor of std::unique_ptr.

Reviewers: NoQ, Szelethus, vsavchenko, xazax.hun

Reviewed By: NoQ

Subscribers: martong, cfe-commits
Tags: #clang

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
clang/test/Analysis/smart-ptr-text-output.cpp
clang/test/Analysis/smart-ptr.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp 
b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
index c405ef12433a..391d038c8766 100644
--- a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -58,6 +58,10 @@ class SmartPtrModeling
   void handleSwap(const CallEvent , CheckerContext ) const;
   void handleGet(const CallEvent , CheckerContext ) const;
   bool handleAssignOp(const CallEvent , CheckerContext ) const;
+  bool handleMoveCtr(const CallEvent , CheckerContext ,
+ const MemRegion *ThisRegion) const;
+  bool updateMovedSmartPointers(CheckerContext , const MemRegion *ThisRegion,
+const MemRegion *OtherSmartPtrRegion) const;
 
   using SmartPtrMethodHandlerFn =
   void (SmartPtrModeling::*)(const CallEvent , CheckerContext &) 
const;
@@ -160,13 +164,16 @@ bool SmartPtrModeling::evalCall(const CallEvent ,
 return false;
 
   if (const auto *CC = dyn_cast()) {
-if (CC->getDecl()->isCopyOrMoveConstructor())
+if (CC->getDecl()->isCopyConstructor())
   return false;
 
 const MemRegion *ThisRegion = CC->getCXXThisVal().getAsRegion();
 if (!ThisRegion)
   return false;
 
+if (CC->getDecl()->isMoveConstructor())
+  return handleMoveCtr(Call, C, ThisRegion);
+
 if (Call.getNumArgs() == 0) {
   auto NullVal = C.getSValBuilder().makeNull();
   State = State->set(ThisRegion, NullVal);
@@ -410,6 +417,22 @@ bool SmartPtrModeling::handleAssignOp(const CallEvent 
,
 return true;
   }
 
+  return updateMovedSmartPointers(C, ThisRegion, OtherSmartPtrRegion);
+}
+
+bool SmartPtrModeling::handleMoveCtr(const CallEvent , CheckerContext ,
+ const MemRegion *ThisRegion) const {
+  const auto *OtherSmartPtrRegion = Call.getArgSVal(0).getAsRegion();
+  if (!OtherSmartPtrRegion)
+return false;
+
+  return updateMovedSmartPointers(C, ThisRegion, OtherSmartPtrRegion);
+}
+
+bool SmartPtrModeling::updateMovedSmartPointers(
+CheckerContext , const MemRegion *ThisRegion,
+const MemRegion *OtherSmartPtrRegion) const {
+  ProgramStateRef State = C.getState();
   const auto *OtherInnerPtr = 
State->get(OtherSmartPtrRegion);
   if (OtherInnerPtr) {
 State = State->set(ThisRegion, *OtherInnerPtr);
@@ -430,7 +453,7 @@ bool SmartPtrModeling::handleAssignOp(const CallEvent ,
 ThisRegion->printPretty(OS);
   }
   if (BR.isInteresting(ThisRegion) && IsArgValNull) {
-OS << "Null pointer value move-assigned to ";
+OS << "A null pointer value is moved to ";
 ThisRegion->printPretty(OS);
 BR.markInteresting(OtherSmartPtrRegion);
   }

diff  --git a/clang/test/Analysis/smart-ptr-text-output.cpp 
b/clang/test/Analysis/smart-ptr-text-output.cpp
index d63cd9b805f8..602a5e94c23a 100644
--- a/clang/test/Analysis/smart-ptr-text-output.cpp
+++ b/clang/test/Analysis/smart-ptr-text-output.cpp
@@ -144,7 +144,7 @@ void derefOnNullPtrGotMovedFromValidPtr() {
   std::unique_ptr P(new A()); // expected-note {{Smart pointer 'P' is 
constructed}}
   // FIXME: above note should go away once we fix marking region not 
interested. 
   std::unique_ptr PToMove; // expected-note {{Default constructed smart 
pointer 'PToMove' is null}}
-  P = std::move(PToMove); // expected-note {{Null pointer value move-assigned 
to 'P'}}
+  P = std::move(PToMove); // expected-note {{A null pointer value is moved to 
'P'}}
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
   // expected-note@-1 {{Dereference of null smart pointer 'P'}}
 }
@@ -170,3 +170,32 @@ void derefOnAssignedZeroToNullSmartPtr() {
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
   // expected-note@-1 {{Dereference of null smart pointer 'P'}}
 }
+
+void derefMoveConstructedWithNullPtr() {
+  std::unique_ptr PToMove; // expected-note {{Default constructed smart 
pointer 'PToMove' is null}}
+  

[PATCH] D86736: [analyzer][NFC] Don't bind values to ObjCForCollectionStmt, replace it with a GDM trait

2020-08-31 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D86736#2247035 , @Szelethus wrote:

> In D86736#2244365 , @martong wrote:
>
>>> For any other loops, in order to know whether we should analyze another 
>>> iteration, among other things, we evaluate it's condition. Which is a 
>>> problem for ObjCForCollectionStmt, because it simply doesn't have one
>>
>> Shouldn't we try to fix the ObjCForCollectionStmt in the AST rather? By 
>> adding the condition to that as a (sub)expression? There are already many 
>> discrepancies and inconsistencies between supposedly similar AST nodes, and 
>> people do fix them occasionally (e.g. D81787 
>> ).
>
> To be fair, before I say anything, I don't know much about Objective C, but I 
> don't think this is a bug. This is just how for each loops are in it. The C++ 
> standard specifies  that ranged based 
> for loops must be equivalent to a pre-C++11 loop, hence the implicit 
> condition in the AST. I think this is the same kind of annoyance we chatted 
> about regarding virtuality in the AST -- even if a method is virtual, it may 
> not show up as such in the AST if the keyword itself is absent.
>
>> To be honest, it seems a bit off to store some parts of the liveness info in 
>> the GDM while other parts not in the GDM ...
>
> There is no liveness to talk about here, it just simply doesn't make sense. 
> This is just a property: "Does this loop have any more iterations left?". 
> While the earlier hack looks convincing that this has something more to it, 
> it really doesn't. In fact, this patch demonstrates it quite well: we only 
> need to keep track of this information until we make a state split, so 
> theoretically, we could just pass this along as a parameter. The only thing 
> holding me back from that solution is that it would be a lot more disruptive 
> change, and would require a change to the `checkBranchCondition` callback.

Ok, fair enough.




Comment at: clang/lib/StaticAnalyzer/Core/ProgramState.cpp:327
+using ObjCForLctxPair =
+std::pair;
+

Why it is not enough to simply have ObjCForCollectionStmt* as a key?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86736

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


[PATCH] D86874: [analyzer] Fix ArrayBoundCheckerV2 false positive regarding size_t indexer

2020-08-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, vsavchenko, Szelethus, martong, balazske, 
baloghadamsoftware.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, arphaman, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, 
whisperity.
Herald added a project: clang.
steakhal requested review of this revision.

Fixes the bug .

  typedef unsigned long long size_t;
  const char a[] = "aabbcc";
  char f1(size_t len) {
return a[len+1]; // false-positive warning: Out of bound memory access 
(access exceeds upper limit of memory block)
  }

Previousl, the analyzer did these things:

1. Calculates the RawOffset of the access, resulting in: BaseRegion: `a` and 
ByteOffset: `len + 1`
2. Checks the lower bound via transforming (//simplifying//) the question `len 
+ 1 < 0` into `len < -1`. However, the analyzer can not prove nor disprove 
this, so it `assume`s that it holds. This assumption will constrain the `len` 
to be `UINT_MAX` since the `<` operator will promote the `-1` into `UINT_MAX`.
3. Checks the upper bound via transforming (//simplifying//) the question `len 
+ 1 >= 7` into `len < 6`. Since the analyzer perfectly constrained `len` at the 
previous step, we wrongly diagnose an out-of-bound error.

Proposed solution:
Skip the lower bound check if the //simplified// root expression (in the 
current example `len`) is `unsigned` and the //simplified// index holds a 
negative value.
We know for sure that no out-of-bound error can happen in this part, since how 
could an unsigned symbolic value be less than a negative constant?
Note that we **don't** deal with wrapping here.

I hope that this fix gets this checker closer to the stage when it can leave 
alpha.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86874

Files:
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
  clang/test/Analysis/out-of-bounds-false-positive.c


Index: clang/test/Analysis/out-of-bounds-false-positive.c
===
--- clang/test/Analysis/out-of-bounds-false-positive.c
+++ clang/test/Analysis/out-of-bounds-false-positive.c
@@ -8,12 +8,11 @@
 const char a[] = "abcd"; // extent: 5 bytes
 
 void symbolic_size_t_and_int0(size_t len) {
-  // FIXME: Should not warn for this.
-  (void)a[len + 1]; // expected-warning {{Out of bound memory access}}
+  (void)a[len + 1]; // no-warning
   // We infered that the 'len' must be in a specific range to make the 
previous indexing valid.
   // len: [0,3]
-  clang_analyzer_eval(len <= 3); // expected - warning {{TRUE}}
-  clang_analyzer_eval(len <= 2); // expected - warning {{UNKNOWN}}
+  clang_analyzer_eval(len <= 3); // expected-warning {{TRUE}}
+  clang_analyzer_eval(len <= 2); // expected-warning {{UNKNOWN}}
 }
 
 void symbolic_size_t_and_int1(size_t len) {
Index: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
@@ -222,6 +222,12 @@
   std::tie(RootNonLoc, ConstantFoldedRHS) =
   simplify(SVB, RawOffset.getByteOffset(), Zero);
 
+  // No unsigned symbolic value can be less then a negative constant.
+  if (const auto SymbolicRoot = RootNonLoc.getAs())
+if (SymbolicRoot->getSymbol()->getType()->isUnsignedIntegerType() &&
+ConstantFoldedRHS.castAs().getValue().isNegative())
+  return State;
+
   NonLoc LowerBoundCheck =
   SVB.evalBinOpNN(State, BO_LT, RootNonLoc.castAs(),
   ConstantFoldedRHS.castAs(),


Index: clang/test/Analysis/out-of-bounds-false-positive.c
===
--- clang/test/Analysis/out-of-bounds-false-positive.c
+++ clang/test/Analysis/out-of-bounds-false-positive.c
@@ -8,12 +8,11 @@
 const char a[] = "abcd"; // extent: 5 bytes
 
 void symbolic_size_t_and_int0(size_t len) {
-  // FIXME: Should not warn for this.
-  (void)a[len + 1]; // expected-warning {{Out of bound memory access}}
+  (void)a[len + 1]; // no-warning
   // We infered that the 'len' must be in a specific range to make the previous indexing valid.
   // len: [0,3]
-  clang_analyzer_eval(len <= 3); // expected - warning {{TRUE}}
-  clang_analyzer_eval(len <= 2); // expected - warning {{UNKNOWN}}
+  clang_analyzer_eval(len <= 3); // expected-warning {{TRUE}}
+  clang_analyzer_eval(len <= 2); // expected-warning {{UNKNOWN}}
 }
 
 void symbolic_size_t_and_int1(size_t len) {
Index: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
@@ -222,6 +222,12 @@
   std::tie(RootNonLoc, ConstantFoldedRHS) =
   simplify(SVB, RawOffset.getByteOffset(), Zero);

[PATCH] D86873: [analyzer][NFC] Refactor ArrayBoundCheckerV2

2020-08-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, vsavchenko, xazax.hun, martong, Szelethus.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
whisperity.
Herald added a project: clang.
steakhal requested review of this revision.

This patch refactors the ArrayBoundCheckerV2 to use more SValVisitor machinery.
IMO this pattern leads to a more functional style, thus more readable - 
compared to an ad-hoc recursion what `getSimplifiedOffsets` did.
I also drastically reduce the scope of the mutated local variables for 
readability.
This resulted in a fairly large change:

- Use `MemRegionVisitor` to compute `RegionRawOffsetV2` of a memory region.
- Use `SymExprVisitor` to //simplify// subscript expression.
- Remove `getSimplifiedOffsets` function.
- Split up `ArrayBoundCheckerV2::checkLocation` into `checkLowerBound` and 
`checkUpperBound`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86873

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

Index: clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
@@ -21,210 +21,309 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
 using namespace ento;
 using namespace taint;
+using ConcreteInt = nonloc::ConcreteInt;
+using SymbolVal = nonloc::SymbolVal;
 
 namespace {
-class ArrayBoundCheckerV2 :
-public Checker {
-  mutable std::unique_ptr BT;
+// FIXME: Eventually replace RegionRawOffset with this class.
+class RegionRawOffsetV2 {
+private:
+  const SubRegion *BaseRegion = nullptr;
+  SVal ByteOffset = UnknownVal();
+
+  RegionRawOffsetV2() = default;
+
+  /// Compute a raw byte offset from a base region.
+  /// Flatten the nested ElementRegion structure into a byte-offset in a
+  /// SubRegion. E.g:
+  ///   dereferenced location:
+  /// {Element{Sym{reg_p}, conj{n, int}, char}, 3, int}
+  /// Finds the base region:
+  ///   Region: Sym{reg_p}
+  /// Builds the corresponding symbolic offset expression:
+  ///   Offset: SymIntExpr{conj{n, int}, +, 12, long long}
+  class RawOffsetCalculator final
+  : public MemRegionVisitor {
+ProgramStateRef State;
+SValBuilder 
+
+RegionRawOffsetV2 Leaf(const SubRegion *R) const {
+  return {R, SVB.makeArrayIndex(0)};
+}
 
-  enum OOB_Kind { OOB_Precedes, OOB_Excedes, OOB_Tainted };
+  public:
+RawOffsetCalculator(ProgramStateRef State, SValBuilder )
+: State(State), SVB(SVB) {}
+using MemRegionVisitor::Visit;
 
-  void reportOOB(CheckerContext , ProgramStateRef errorState, OOB_Kind kind,
- std::unique_ptr Visitor = nullptr) const;
+auto VisitMemRegion(const MemRegion *R) {
+  return Leaf(dyn_cast(R));
+}
 
-public:
-  void checkLocation(SVal l, bool isLoad, const Stmt*S,
- CheckerContext ) const;
-};
+RegionRawOffsetV2 VisitElementRegion(const ElementRegion *ER) {
+  // For: Elem{SuperReg, ElemTy, ElemIdx}
+  // 1) Calculate the raw offset of the SuperReg.
+  // 2) Handle the current level.
+  //Offset := Offset + sizeof(ElemTy) * ElemIdx
+  const RegionRawOffsetV2 RawOffset = Visit(ER->getSuperRegion());
 
-// FIXME: Eventually replace RegionRawOffset with this class.
-class RegionRawOffsetV2 {
-private:
-  const SubRegion *baseRegion;
-  SVal byteOffset;
+  const QualType ElemTy = ER->getElementType();
+  const NonLoc Index = ER->getIndex();
+
+  // If we can not calculate the sizeof ElemTy, erase result and give up.
+  if (ElemTy->isIncompleteType())
+return Leaf(nullptr);
+
+  const NonLoc SizeofElemTy = SVB.makeArrayIndex(
+  SVB.getContext().getTypeSizeInChars(ElemTy).getQuantity());
 
-  RegionRawOffsetV2()
-: baseRegion(nullptr), byteOffset(UnknownVal()) {}
+  const QualType ArrayIndexTy = SVB.getArrayIndexType();
+  const NonLoc ByteElementOffset =
+  SVB.evalBinOpNN(State, BO_Mul, Index, SizeofElemTy, ArrayIndexTy)
+  .castAs();
+
+  SVal NewByteOffset = SVB.evalBinOpNN(
+  State, BO_Add, RawOffset.getByteOffset().castAs(),
+  ByteElementOffset, ArrayIndexTy);
+  return {RawOffset.getRegion(), NewByteOffset};
+}
+  };
 
 public:
-  RegionRawOffsetV2(const SubRegion* base, SVal offset)
-: baseRegion(base), byteOffset(offset) {}
+  RegionRawOffsetV2(const SubRegion *BaseRegion, SVal ByteOffset)
+  : BaseRegion(BaseRegion), 

[PATCH] D86870: [analyzer] Add more tests for ArrayBoundCheckerV2

2020-08-31 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, vsavchenko, xazax.hun, Szelethus, martong.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
whisperity.
Herald added a project: clang.
steakhal requested review of this revision.

According to a Bugzilla ticket  
produces a false-positive report.
This patch adds a test demonstrating the current //flawed// behavior.
Also adds several similar test cases just to be on the safe side.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86870

Files:
  clang/test/Analysis/out-of-bounds-false-positive.c

Index: clang/test/Analysis/out-of-bounds-false-positive.c
===
--- /dev/null
+++ clang/test/Analysis/out-of-bounds-false-positive.c
@@ -0,0 +1,101 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.security.ArrayBoundV2,debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false -verify %s
+
+void clang_analyzer_eval(int);
+void clang_analyzer_printState();
+
+typedef unsigned long long size_t;
+const char a[] = "abcd"; // extent: 5 bytes
+
+void symbolic_size_t_and_int0(size_t len) {
+  // FIXME: Should not warn for this.
+  (void)a[len + 1]; // expected-warning {{Out of bound memory access}}
+  // We infered that the 'len' must be in a specific range to make the previous indexing valid.
+  // len: [0,3]
+  clang_analyzer_eval(len <= 3); // expected - warning {{TRUE}}
+  clang_analyzer_eval(len <= 2); // expected - warning {{UNKNOWN}}
+}
+
+void symbolic_size_t_and_int1(size_t len) {
+  (void)a[len]; // no-warning
+  // len: [0,4]
+  clang_analyzer_eval(len <= 4); // expected-warning {{TRUE}}
+  clang_analyzer_eval(len <= 3); // expected-warning {{UNKNOWN}}
+}
+
+void symbolic_size_t_and_int2(size_t len) {
+  (void)a[len - 1]; // no-warning
+  // len: [1,5]
+  clang_analyzer_eval(1 <= len && len <= 5); // expected-warning {{TRUE}}
+  clang_analyzer_eval(2 <= len); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(len <= 4); // expected-warning {{UNKNOWN}}
+}
+
+void symbolic_uint_and_int0(unsigned len) {
+  (void)a[len + 1]; // no-warning
+  // len: [0,3]
+  clang_analyzer_eval(0 <= len && len <= 3); // expected-warning {{TRUE}}
+  clang_analyzer_eval(1 <= len); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(len <= 2); // expected-warning {{UNKNOWN}}
+}
+
+void symbolic_uint_and_int1(unsigned len) {
+  (void)a[len]; // no-warning
+  // len: [0,4]
+  clang_analyzer_eval(0 <= len && len <= 4); // expected-warning {{TRUE}}
+  clang_analyzer_eval(1 <= len); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(len <= 3); // expected-warning {{UNKNOWN}}
+}
+void symbolic_uint_and_int2(unsigned len) {
+  (void)a[len - 1]; // no-warning
+  // len: [1,5]
+  clang_analyzer_eval(1 <= len && len <= 5); // expected-warning {{TRUE}}
+  clang_analyzer_eval(2 <= len); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(len <= 4); // expected-warning {{UNKNOWN}}
+}
+
+void symbolic_int_and_int0(int len) {
+  (void)a[len + 1]; // no-warning
+  // len: [-1,3]
+  clang_analyzer_eval(-1 <= len && len <= 3); // expected-warning {{TRUE}}
+  clang_analyzer_eval(0 <= len);  // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(len <= 2);  // expected-warning {{UNKNOWN}}
+}
+void symbolic_int_and_int1(int len) {
+  (void)a[len]; // no-warning
+  // len: [0,4]
+  clang_analyzer_eval(0 <= len && len <= 4); // expected-warning {{TRUE}}
+  clang_analyzer_eval(1 <= len); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(len <= 3); // expected-warning {{UNKNOWN}}
+}
+void symbolic_int_and_int2(int len) {
+  (void)a[len - 1]; // no-warning
+  // len: [1,5]
+  clang_analyzer_eval(1 <= len && len <= 5); // expected-warning {{TRUE}}
+  clang_analyzer_eval(2 <= len); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(len <= 4); // expected-warning {{UNKNOWN}}
+}
+
+void symbolic_longlong_and_int0(long long len) {
+  (void)a[len + 1]; // no-warning
+  // len: [-1,3]
+  clang_analyzer_eval(-1 <= len && len <= 3); // expected-warning {{TRUE}}
+  clang_analyzer_eval(0 <= len);  // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(len <= 2);  // expected-warning {{UNKNOWN}}
+}
+
+void symbolic_longlong_and_int1(long long len) {
+  (void)a[len]; // no-warning
+  // len: [0,4]
+  clang_analyzer_eval(0 <= len && len <= 4); // expected-warning {{TRUE}}
+  clang_analyzer_eval(1 <= len); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(len <= 3); // expected-warning {{UNKNOWN}}
+}
+
+void symbolic_longlong_and_int2(long long len) {
+  (void)a[len - 1]; // no-warning
+  // len: [1,5]
+  clang_analyzer_eval(1 

[PATCH] D86089: [flang][driver]Add experimental flang driver and frontend with help screen

2020-08-31 Thread sameeran joshi via Phabricator via cfe-commits
sameeranjoshi accepted this revision.
sameeranjoshi added a comment.

Thank you for changes.
I was able to build successfully out-of-tree.
Please update the `README.md` with the necessary changes.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86089

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


[PATCH] D85032: [builtins] Make divXf3 handle denormal results

2020-08-31 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff accepted this revision.
sepavloff added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85032

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


[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-08-31 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

The new comments are much better, thank you!
I think this version may be committed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85031

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


[PATCH] D77491: [Sema] Introduce BuiltinAttr, per-declaration builtin-ness

2020-08-31 Thread Raul Tambre via Phabricator via cfe-commits
tambre added inline comments.



Comment at: clang/include/clang/Basic/IdentifierTable.h:231
 return ObjCOrBuiltinID == tok::NUM_OBJC_KEYWORDS;
   }
 

rjmccall wrote:
> Do we need to support reverting builtins anymore?
We don't. It'd be possible to set the builtin ID of identifiers to `0` as an 
optimization to avoid declaration compatibility checking if there's a 
declaration that would hide the actual builtin. But I doubt it's worth it.

I've removed code related to this, as nothing was actually checking the 
reverted status anymore.



Comment at: clang/test/CodeGen/callback_pthread_create.c:3
+// RUN: false
+// XFAIL: *
+

rjmccall wrote:
> I guess the problem with pthread_create is that the types are not really 
> reasonable to synthesize.  I wonder if we can use an approach more like what 
> we do with C++, where we don't magically synthesize a declaration but where 
> we do recognize that a particular declaration is compatible with the builtin 
> signature.
Seems like a good idea. Would also reduce code duplication between C and C++. I 
would be willing to look into that as a followup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77491

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


[PATCH] D77491: [Sema] Introduce BuiltinAttr, per-declaration builtin-ness

2020-08-31 Thread Raul Tambre via Phabricator via cfe-commits
tambre updated this revision to Diff 288911.
tambre marked 2 inline comments as done.
tambre added a comment.

Remove builtin reverting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77491

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Headers/intrin.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/AST/ast-dump-attr.cpp
  clang/test/Analysis/bstring.cpp
  clang/test/CodeGen/builtin-redeclaration.c
  clang/test/CodeGen/callback_pthread_create.c
  clang/test/Sema/implicit-builtin-decl.c
  clang/test/Sema/warn-fortify-source.c
  clang/test/SemaCXX/cxx11-compat.cpp
  clang/test/SemaCXX/warn-unused-local-typedef.cpp

Index: clang/test/SemaCXX/warn-unused-local-typedef.cpp
===
--- clang/test/SemaCXX/warn-unused-local-typedef.cpp
+++ clang/test/SemaCXX/warn-unused-local-typedef.cpp
@@ -67,10 +67,10 @@
 
 void test() {
   typedef signed long int superint; // no diag
-  printf("%f", (superint) 42);
+  printf("%ld", (superint)42);
 
   typedef signed long int superint2; // no diag
-  printf("%f", static_cast(42));
+  printf("%ld", static_cast(42));
 
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wunused-local-typedef"
Index: clang/test/SemaCXX/cxx11-compat.cpp
===
--- clang/test/SemaCXX/cxx11-compat.cpp
+++ clang/test/SemaCXX/cxx11-compat.cpp
@@ -31,7 +31,7 @@
 s = { n }, // expected-warning {{non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list in C++11}} expected-note {{explicit cast}}
 t = { 1234 }; // expected-warning {{constant expression evaluates to 1234 which cannot be narrowed to type 'char' in C++11}} expected-warning {{changes value}} expected-note {{explicit cast}}
 
-#define PRIuS "uS"
+#define PRIuS "zu"
 int printf(const char *, ...);
 typedef __typeof(sizeof(int)) size_t;
 void h(size_t foo, size_t bar) {
Index: clang/test/Sema/warn-fortify-source.c
===
--- clang/test/Sema/warn-fortify-source.c
+++ clang/test/Sema/warn-fortify-source.c
@@ -1,8 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 %s -verify
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 %s -verify -DUSE_PASS_OBJECT_SIZE
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 %s -verify -DUSE_BUILTINS
 // RUN: %clang_cc1 -xc++ -triple x86_64-apple-macosx10.14.0 %s -verify
-// RUN: %clang_cc1 -xc++ -triple x86_64-apple-macosx10.14.0 %s -verify -DUSE_PASS_OBJECT_SIZE
 // RUN: %clang_cc1 -xc++ -triple x86_64-apple-macosx10.14.0 %s -verify -DUSE_BUILTINS
 
 typedef unsigned long size_t;
@@ -13,13 +11,7 @@
 
 extern int sprintf(char *str, const char *format, ...);
 
-#if defined(USE_PASS_OBJECT_SIZE)
-void *memcpy(void *dst, const void *src, size_t c);
-static void *memcpy(void *dst __attribute__((pass_object_size(1))), const void *src, size_t c) __attribute__((overloadable)) __asm__("merp");
-static void *memcpy(void *const dst __attribute__((pass_object_size(1))), const void *src, size_t c) __attribute__((overloadable)) {
-  return 0;
-}
-#elif defined(USE_BUILTINS)
+#if defined(USE_BUILTINS)
 #define memcpy(x,y,z) __builtin_memcpy(x,y,z)
 #else
 void *memcpy(void *dst, const void *src, size_t c);
@@ -45,14 +37,7 @@
   };
   struct pair p;
   char buf[20];
-  memcpy(, buf, 20);
-#ifdef USE_PASS_OBJECT_SIZE
-  // Use the more strict checking mode on the pass_object_size attribute:
-  // expected-warning@-3 {{memcpy' will always overflow; destination buffer has size 4, but size argument is 20}}
-#else
-  // Or just fallback to type 0:
-  // expected-warning@-6 {{memcpy' will always overflow; destination buffer has size 8, but size argument is 20}}
-#endif
+  memcpy(, buf, 20); // expected-warning {{memcpy' will always overflow; destination buffer has size 8, but size argument is 20}}
 }
 
 void call_strncat() {
Index: clang/test/Sema/implicit-builtin-decl.c
===
--- clang/test/Sema/implicit-builtin-decl.c
+++ clang/test/Sema/implicit-builtin-decl.c
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: not %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s
 
 void f() {
   int *ptr = malloc(sizeof(int) * 10); // expected-warning{{implicitly declaring library function 'malloc' with type}} \
@@ -63,9 +62,5 @@
 struct __jmp_buf_tag {};
 void sigsetjmp(struct __jmp_buf_tag[1], int); // expected-warning{{declaration of built-in function 'sigsetjmp' requires the declaration of the 'jmp_buf' type, commonly provided in the header .}}
 

[PATCH] D86027: [analyzer] Add bool operator modeling for unque_ptr

2020-08-31 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.
Herald added a subscriber: danielkiss.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:556
+const LocationContext *LC = C.getLocationContext();
+InnerPointerVal = C.getSValBuilder().conjureSymbolVal(
+CallExpr, LC, InnerPointerType, C.blockCount());

Don't we want to actually add InnerPointerVal to TrackedRegionMap in this case?

I might be wrong but I cannot find where do we actually record the fact that 
this freshly conjured symbol belongs to the unique_ptr we are modeling.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86027

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


  1   2   >