[PATCH] D80461: HIP: Try to deal with more llvm package layouts

2020-05-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

1d96dca9491e3d75c11c3cd1acff5fcda8c2f613 



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

https://reviews.llvm.org/D80461



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


[PATCH] D78938: Fixing all comparisons for C++20 compilation.

2020-05-25 Thread Barry Revzin via Phabricator via cfe-commits
BRevzin updated this revision to Diff 265874.
BRevzin added a comment.
Herald added a subscriber: martong.

- A few more changes from tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938

Files:
  clang/include/clang/AST/StmtIterator.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  llvm/include/llvm/ADT/AllocatorList.h
  llvm/include/llvm/ADT/DenseMap.h
  llvm/include/llvm/ADT/DenseSet.h
  llvm/include/llvm/ADT/DirectedGraph.h
  llvm/include/llvm/ADT/STLExtras.h
  llvm/include/llvm/ADT/StringMap.h
  llvm/include/llvm/ADT/iterator.h
  llvm/include/llvm/CodeGen/LiveInterval.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/BasicBlock.h
  llvm/include/llvm/Object/StackMapParser.h
  llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h
  llvm/include/llvm/ProfileData/InstrProfReader.h
  llvm/include/llvm/Support/BinaryStreamRef.h
  llvm/lib/CodeGen/MachineOutliner.cpp
  llvm/lib/CodeGen/PeepholeOptimizer.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/DebugInfo.cpp
  llvm/lib/Transforms/Scalar/GVNHoist.cpp
  llvm/unittests/ADT/STLExtrasTest.cpp
  llvm/unittests/Support/DJBTest.cpp
  llvm/unittests/Support/JSONTest.cpp

Index: llvm/unittests/Support/JSONTest.cpp
===
--- llvm/unittests/Support/JSONTest.cpp
+++ llvm/unittests/Support/JSONTest.cpp
@@ -173,12 +173,14 @@
   Compare(R"("\"\\\b\f\n\r\t")", "\"\\\b\f\n\r\t");
   Compare(R"("\u")", llvm::StringRef("\0", 1));
   Compare("\"\x7f\"", "\x7f");
+#ifndef __cpp_char8_t
   Compare(R"("\ud801\udc37")", u8"\U00010437"); // UTF16 surrogate pair escape.
   Compare("\"\xE2\x82\xAC\xF0\x9D\x84\x9E\"", u8"\u20ac\U0001d11e"); // UTF8
   Compare(
   R"("LoneLeading=\ud801, LoneTrailing=\udc01, LeadingLeadingTrailing=\ud801\ud801\udc37")",
   u8"LoneLeading=\ufffd, LoneTrailing=\ufffd, "
   u8"LeadingLeadingTrailing=\ufffd\U00010437"); // Invalid unicode.
+#endif
 
   Compare(R"({"":0,"":0})", Object{{"", 0}});
   Compare(R"({"obj":{},"arr":[]})", Object{{"obj", Object{}}, {"arr", {}}});
Index: llvm/unittests/Support/DJBTest.cpp
===
--- llvm/unittests/Support/DJBTest.cpp
+++ llvm/unittests/Support/DJBTest.cpp
@@ -24,6 +24,7 @@
   {{""}, {""}},
 
   {{"I"}, {"i"}},
+#ifndef __cpp_char8_t
   // Latin Small Letter Dotless I
   {{u8"\u0130"}, {"i"}},
   // Latin Capital Letter I With Dot Above
@@ -47,6 +48,7 @@
   {{u8"\uff2d"}, {u8"\uff4d"}},
   // Old Hungarian Capital Letter Ej
   {{u8"\U00010c92"}, {u8"\U00010cd2"}},
+#endif
   };
 
   for (const TestCase  : Tests) {
@@ -79,6 +81,7 @@
   }
 }
 
+#ifndef __cpp_char8_t
 TEST(DJBTest, knownValuesUnicode) {
   EXPECT_EQ(5866553u, djbHash(u8"\u0130"));
   EXPECT_EQ(177678u, caseFoldingDjbHash(u8"\u0130"));
@@ -93,3 +96,4 @@
   u8"\u0130\u0131\u00c0\u00e0\u0100\u0101\u0139\u013a\u0415\u0435\u1ea6"
   u8"\u1ea7\u212a\u006b\u2c1d\u2c4d\uff2d\uff4d\U00010c92\U00010cd2"));
 }
+#endif
\ No newline at end of file
Index: llvm/unittests/ADT/STLExtrasTest.cpp
===
--- llvm/unittests/ADT/STLExtrasTest.cpp
+++ llvm/unittests/ADT/STLExtrasTest.cpp
@@ -463,21 +463,21 @@
 
   // Check fancy pointer overload for unique_ptr
   std::unique_ptr V2 = std::make_unique(0);
-  EXPECT_EQ(V2.get(), to_address(V2));
+  EXPECT_EQ(V2.get(), (to_address)(V2));
 
   V2.reset(V1);
-  EXPECT_EQ(V1, to_address(V2));
+  EXPECT_EQ(V1, (to_address)(V2));
   V2.release();
 
   // Check fancy pointer overload for shared_ptr
   std::shared_ptr V3 = std::make_shared(0);
   std::shared_ptr V4 = V3;
   EXPECT_EQ(V3.get(), V4.get());
-  EXPECT_EQ(V3.get(), to_address(V3));
-  EXPECT_EQ(V4.get(), to_address(V4));
+  EXPECT_EQ(V3.get(), (to_address)(V3));
+  EXPECT_EQ(V4.get(), (to_address)(V4));
 
   V3.reset(V1);
-  EXPECT_EQ(V1, to_address(V3));
+  EXPECT_EQ(V1, (to_address)(V3));
 }
 
 TEST(STLExtrasTest, partition_point) {
Index: llvm/lib/Transforms/Scalar/GVNHoist.cpp
===
--- llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -149,8 +149,8 @@
   // The instruction (VN) which uses the values flowing out of CHI.
   Instruction *I;
 
-  bool operator==(const CHIArg ) { return VN == A.VN; }
-  bool operator!=(const CHIArg ) { return !(*this == A); }
+  bool operator==(const CHIArg ) const { return VN == A.VN; }
+  bool operator!=(const CHIArg ) const { return !(*this == A); }
 };
 
 using CHIIt = SmallVectorImpl::iterator;
Index: llvm/lib/IR/DebugInfo.cpp
===
--- llvm/lib/IR/DebugInfo.cpp
+++ llvm/lib/IR/DebugInfo.cpp
@@ -665,7 +665,7 @@
   if (auto 

[PATCH] D78938: Fixing all comparisons for C++20 compilation.

2020-05-25 Thread Barry Revzin via Phabricator via cfe-commits
BRevzin updated this revision to Diff 265875.
BRevzin added a comment.

- Adding missing return.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938

Files:
  clang/include/clang/AST/StmtIterator.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  llvm/include/llvm/ADT/AllocatorList.h
  llvm/include/llvm/ADT/DenseMap.h
  llvm/include/llvm/ADT/DenseSet.h
  llvm/include/llvm/ADT/DirectedGraph.h
  llvm/include/llvm/ADT/STLExtras.h
  llvm/include/llvm/ADT/StringMap.h
  llvm/include/llvm/ADT/iterator.h
  llvm/include/llvm/CodeGen/LiveInterval.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/BasicBlock.h
  llvm/include/llvm/Object/StackMapParser.h
  llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h
  llvm/include/llvm/ProfileData/InstrProfReader.h
  llvm/include/llvm/Support/BinaryStreamRef.h
  llvm/lib/CodeGen/MachineOutliner.cpp
  llvm/lib/CodeGen/PeepholeOptimizer.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/DebugInfo.cpp
  llvm/lib/Transforms/Scalar/GVNHoist.cpp
  llvm/unittests/ADT/STLExtrasTest.cpp
  llvm/unittests/Support/DJBTest.cpp
  llvm/unittests/Support/JSONTest.cpp

Index: llvm/unittests/Support/JSONTest.cpp
===
--- llvm/unittests/Support/JSONTest.cpp
+++ llvm/unittests/Support/JSONTest.cpp
@@ -173,12 +173,14 @@
   Compare(R"("\"\\\b\f\n\r\t")", "\"\\\b\f\n\r\t");
   Compare(R"("\u")", llvm::StringRef("\0", 1));
   Compare("\"\x7f\"", "\x7f");
+#ifndef __cpp_char8_t
   Compare(R"("\ud801\udc37")", u8"\U00010437"); // UTF16 surrogate pair escape.
   Compare("\"\xE2\x82\xAC\xF0\x9D\x84\x9E\"", u8"\u20ac\U0001d11e"); // UTF8
   Compare(
   R"("LoneLeading=\ud801, LoneTrailing=\udc01, LeadingLeadingTrailing=\ud801\ud801\udc37")",
   u8"LoneLeading=\ufffd, LoneTrailing=\ufffd, "
   u8"LeadingLeadingTrailing=\ufffd\U00010437"); // Invalid unicode.
+#endif
 
   Compare(R"({"":0,"":0})", Object{{"", 0}});
   Compare(R"({"obj":{},"arr":[]})", Object{{"obj", Object{}}, {"arr", {}}});
Index: llvm/unittests/Support/DJBTest.cpp
===
--- llvm/unittests/Support/DJBTest.cpp
+++ llvm/unittests/Support/DJBTest.cpp
@@ -24,6 +24,7 @@
   {{""}, {""}},
 
   {{"I"}, {"i"}},
+#ifndef __cpp_char8_t
   // Latin Small Letter Dotless I
   {{u8"\u0130"}, {"i"}},
   // Latin Capital Letter I With Dot Above
@@ -47,6 +48,7 @@
   {{u8"\uff2d"}, {u8"\uff4d"}},
   // Old Hungarian Capital Letter Ej
   {{u8"\U00010c92"}, {u8"\U00010cd2"}},
+#endif
   };
 
   for (const TestCase  : Tests) {
@@ -79,6 +81,7 @@
   }
 }
 
+#ifndef __cpp_char8_t
 TEST(DJBTest, knownValuesUnicode) {
   EXPECT_EQ(5866553u, djbHash(u8"\u0130"));
   EXPECT_EQ(177678u, caseFoldingDjbHash(u8"\u0130"));
@@ -93,3 +96,4 @@
   u8"\u0130\u0131\u00c0\u00e0\u0100\u0101\u0139\u013a\u0415\u0435\u1ea6"
   u8"\u1ea7\u212a\u006b\u2c1d\u2c4d\uff2d\uff4d\U00010c92\U00010cd2"));
 }
+#endif
\ No newline at end of file
Index: llvm/unittests/ADT/STLExtrasTest.cpp
===
--- llvm/unittests/ADT/STLExtrasTest.cpp
+++ llvm/unittests/ADT/STLExtrasTest.cpp
@@ -463,21 +463,21 @@
 
   // Check fancy pointer overload for unique_ptr
   std::unique_ptr V2 = std::make_unique(0);
-  EXPECT_EQ(V2.get(), to_address(V2));
+  EXPECT_EQ(V2.get(), (to_address)(V2));
 
   V2.reset(V1);
-  EXPECT_EQ(V1, to_address(V2));
+  EXPECT_EQ(V1, (to_address)(V2));
   V2.release();
 
   // Check fancy pointer overload for shared_ptr
   std::shared_ptr V3 = std::make_shared(0);
   std::shared_ptr V4 = V3;
   EXPECT_EQ(V3.get(), V4.get());
-  EXPECT_EQ(V3.get(), to_address(V3));
-  EXPECT_EQ(V4.get(), to_address(V4));
+  EXPECT_EQ(V3.get(), (to_address)(V3));
+  EXPECT_EQ(V4.get(), (to_address)(V4));
 
   V3.reset(V1);
-  EXPECT_EQ(V1, to_address(V3));
+  EXPECT_EQ(V1, (to_address)(V3));
 }
 
 TEST(STLExtrasTest, partition_point) {
Index: llvm/lib/Transforms/Scalar/GVNHoist.cpp
===
--- llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -149,8 +149,8 @@
   // The instruction (VN) which uses the values flowing out of CHI.
   Instruction *I;
 
-  bool operator==(const CHIArg ) { return VN == A.VN; }
-  bool operator!=(const CHIArg ) { return !(*this == A); }
+  bool operator==(const CHIArg ) const { return VN == A.VN; }
+  bool operator!=(const CHIArg ) const { return !(*this == A); }
 };
 
 using CHIIt = SmallVectorImpl::iterator;
Index: llvm/lib/IR/DebugInfo.cpp
===
--- llvm/lib/IR/DebugInfo.cpp
+++ llvm/lib/IR/DebugInfo.cpp
@@ -665,7 +665,7 @@
   if (auto *T = dyn_cast_or_null(Attachment.second))

[clang] 1d96dca - HIP: Try to deal with more llvm package layouts

2020-05-25 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2020-05-23T13:28:24-04:00
New Revision: 1d96dca9491e3d75c11c3cd1acff5fcda8c2f613

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

LOG: HIP: Try to deal with more llvm package layouts

The various HIP builds are all inconsistent.

The default llvm install goes to ${INSTALL_PREFIX}/bin/clang, but the
rocm packaging scripts move this under
${INSTALL_PREFIX}/llvm/bin/clang. Some other builds further pollute
this with ${INSTALL_PREFIX}/bin/x86_64/clang. These should really be
consolidated, but try to handle them for now.

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 193ccad98f52..3e51bd00bae4 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -107,11 +107,18 @@ RocmInstallationDetector::RocmInstallationDetector(
 // the Windows-esque layout the ROCm packages use with the host 
architecture
 // subdirectory of bin.
 
+// Strip off directory (usually bin)
 StringRef ParentDir = llvm::sys::path::parent_path(InstallDir);
-if (ParentDir == HostTriple.getArchName())
+StringRef ParentName = llvm::sys::path::filename(ParentDir);
+
+// Some builds use bin/{host arch}, so go up again.
+if (ParentName == "bin") {
   ParentDir = llvm::sys::path::parent_path(ParentDir);
+  ParentName = llvm::sys::path::filename(ParentDir);
+}
 
-if (ParentDir == "bin") {
+if (ParentName == "llvm") {
+  // Some versions of the rocm llvm package install to /opt/rocm/llvm/bin
   Candidates.emplace_back(llvm::sys::path::parent_path(ParentDir).str(),
   /*StrictChecking=*/true);
 }



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


[PATCH] D78938: Fixing all comparisons for C++20 compilation.

2020-05-25 Thread Barry Revzin via Phabricator via cfe-commits
BRevzin marked 2 inline comments as done.
BRevzin added a comment.

I hadn't build the tests before, updated with a few more changes. Some of the 
tests require `u8` literals, whose type changes in C++20. I had no idea what to 
do with that, so I just `#ifdef`-ed out those tests with the appropriate 
feature test macro.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938



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


[PATCH] D79945: [Sema] Comparison of pointers to complete and incomplete types

2020-05-25 Thread Benson Chu via Phabricator via cfe-commits
pestctrl updated this revision to Diff 265907.
pestctrl added a comment.

Both extension and extwarn need to be in the c99-extensions group


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79945

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/c89.c


Index: clang/test/Sema/c89.c
===
--- clang/test/Sema/c89.c
+++ clang/test/Sema/c89.c
@@ -127,3 +127,11 @@
   struct Test17 t1 = test17_aux(); /* this is allowed */
 }
 
+int incomplete[]; /* expected-warning {{tentative array definition assumed to 
have one element}} */
+int complete[5];
+
+void test18() {
+  if ( < ) { /* expected-warning {{ordered comparison of 
complete and incomplete pointers}} */
+return;
+  }
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11422,11 +11422,23 @@
 // C99 6.5.9p2 and C99 6.5.8p2
 if (Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
RCanPointeeTy.getUnqualifiedType())) {
-  // Valid unless a relational comparison of function pointers
-  if (IsRelational && LCanPointeeTy->isFunctionType()) {
-Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
-  << LHSType << RHSType << LHS.get()->getSourceRange()
-  << RHS.get()->getSourceRange();
+  if (IsRelational) {
+// Pointers both need to point to complete or incomplete types
+if (LCanPointeeTy->isIncompleteType() !=
+RCanPointeeTy->isIncompleteType()) {
+  Diag(Loc,
+   getLangOpts().C11
+   ? diag::ext_typecheck_compare_complete_incomplete_pointers
+   : diag::warn_typecheck_compare_complete_incomplete_pointers)
+  << LHSType << RHSType << LHS.get()->getSourceRange()
+  << RHS.get()->getSourceRange();
+}
+if (LCanPointeeTy->isFunctionType()) {
+  // Valid unless a relational comparison of function pointers
+  Diag(Loc, 
diag::ext_typecheck_ordered_comparison_of_function_pointers)
+  << LHSType << RHSType << LHS.get()->getSourceRange()
+  << RHS.get()->getSourceRange();
+}
   }
 } else if (!IsRelational &&
(LCanPointeeTy->isVoidType() || RCanPointeeTy->isVoidType())) {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6441,6 +6441,12 @@
   "ordered comparison between pointer and zero (%0 and %1)">;
 def err_typecheck_three_way_comparison_of_pointer_and_zero : Error<
   "three-way comparison between pointer and zero">;
+def ext_typecheck_compare_complete_incomplete_pointers : Extension<
+  "ordered comparison of complete and incomplete pointers (%0 and %1)">
+  InGroup;
+def warn_typecheck_compare_complete_incomplete_pointers : ExtWarn<
+  "ordered comparison of complete and incomplete pointers (%0 and %1)">,
+  InGroup;
 def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn<
   "ordered comparison of function pointers (%0 and %1)">,
   InGroup>;


Index: clang/test/Sema/c89.c
===
--- clang/test/Sema/c89.c
+++ clang/test/Sema/c89.c
@@ -127,3 +127,11 @@
   struct Test17 t1 = test17_aux(); /* this is allowed */
 }
 
+int incomplete[]; /* expected-warning {{tentative array definition assumed to have one element}} */
+int complete[5];
+
+void test18() {
+  if ( < ) { /* expected-warning {{ordered comparison of complete and incomplete pointers}} */
+return;
+  }
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11422,11 +11422,23 @@
 // C99 6.5.9p2 and C99 6.5.8p2
 if (Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
RCanPointeeTy.getUnqualifiedType())) {
-  // Valid unless a relational comparison of function pointers
-  if (IsRelational && LCanPointeeTy->isFunctionType()) {
-Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
-  << LHSType << RHSType << LHS.get()->getSourceRange()
-  << RHS.get()->getSourceRange();
+  if (IsRelational) {
+// Pointers both need to point to complete or incomplete types
+if (LCanPointeeTy->isIncompleteType() !=
+RCanPointeeTy->isIncompleteType()) {
+  Diag(Loc,
+   getLangOpts().C11
+   ? diag::ext_typecheck_compare_complete_incomplete_pointers
+   : 

[PATCH] D79945: [Sema] Comparison of pointers to complete and incomplete types

2020-05-25 Thread Benson Chu via Phabricator via cfe-commits
pestctrl updated this revision to Diff 265908.
pestctrl added a comment.

Rebase on master.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79945

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/c89.c


Index: clang/test/Sema/c89.c
===
--- clang/test/Sema/c89.c
+++ clang/test/Sema/c89.c
@@ -127,3 +127,11 @@
   struct Test17 t1 = test17_aux(); /* this is allowed */
 }
 
+int incomplete[]; /* expected-warning {{tentative array definition assumed to 
have one element}} */
+int complete[5];
+
+void test18() {
+  if ( < ) { /* expected-warning {{ordered comparison of 
complete and incomplete pointers}} */
+return;
+  }
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11422,11 +11422,23 @@
 // C99 6.5.9p2 and C99 6.5.8p2
 if (Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
RCanPointeeTy.getUnqualifiedType())) {
-  // Valid unless a relational comparison of function pointers
-  if (IsRelational && LCanPointeeTy->isFunctionType()) {
-Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
-  << LHSType << RHSType << LHS.get()->getSourceRange()
-  << RHS.get()->getSourceRange();
+  if (IsRelational) {
+// Pointers both need to point to complete or incomplete types
+if (LCanPointeeTy->isIncompleteType() !=
+RCanPointeeTy->isIncompleteType()) {
+  Diag(Loc,
+   getLangOpts().C11
+   ? diag::ext_typecheck_compare_complete_incomplete_pointers
+   : diag::warn_typecheck_compare_complete_incomplete_pointers)
+  << LHSType << RHSType << LHS.get()->getSourceRange()
+  << RHS.get()->getSourceRange();
+}
+if (LCanPointeeTy->isFunctionType()) {
+  // Valid unless a relational comparison of function pointers
+  Diag(Loc, 
diag::ext_typecheck_ordered_comparison_of_function_pointers)
+  << LHSType << RHSType << LHS.get()->getSourceRange()
+  << RHS.get()->getSourceRange();
+}
   }
 } else if (!IsRelational &&
(LCanPointeeTy->isVoidType() || RCanPointeeTy->isVoidType())) {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6441,6 +6441,12 @@
   "ordered comparison between pointer and zero (%0 and %1)">;
 def err_typecheck_three_way_comparison_of_pointer_and_zero : Error<
   "three-way comparison between pointer and zero">;
+def ext_typecheck_compare_complete_incomplete_pointers : Extension<
+  "ordered comparison of complete and incomplete pointers (%0 and %1)">
+  InGroup;
+def warn_typecheck_compare_complete_incomplete_pointers : ExtWarn<
+  "ordered comparison of complete and incomplete pointers (%0 and %1)">,
+  InGroup;
 def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn<
   "ordered comparison of function pointers (%0 and %1)">,
   InGroup>;


Index: clang/test/Sema/c89.c
===
--- clang/test/Sema/c89.c
+++ clang/test/Sema/c89.c
@@ -127,3 +127,11 @@
   struct Test17 t1 = test17_aux(); /* this is allowed */
 }
 
+int incomplete[]; /* expected-warning {{tentative array definition assumed to have one element}} */
+int complete[5];
+
+void test18() {
+  if ( < ) { /* expected-warning {{ordered comparison of complete and incomplete pointers}} */
+return;
+  }
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11422,11 +11422,23 @@
 // C99 6.5.9p2 and C99 6.5.8p2
 if (Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
RCanPointeeTy.getUnqualifiedType())) {
-  // Valid unless a relational comparison of function pointers
-  if (IsRelational && LCanPointeeTy->isFunctionType()) {
-Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
-  << LHSType << RHSType << LHS.get()->getSourceRange()
-  << RHS.get()->getSourceRange();
+  if (IsRelational) {
+// Pointers both need to point to complete or incomplete types
+if (LCanPointeeTy->isIncompleteType() !=
+RCanPointeeTy->isIncompleteType()) {
+  Diag(Loc,
+   getLangOpts().C11
+   ? diag::ext_typecheck_compare_complete_incomplete_pointers
+   : 

[PATCH] D80425: Fix LLVM/Clang builds with mingw toolchain

2020-05-25 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80425



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


[clang] e60de8c - Add missing test

2020-05-25 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2020-05-24T22:50:50+01:00
New Revision: e60de8c825d3087dca26d97985febbf97e179311

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

LOG: Add missing test

Added: 


Modified: 
clang/lib/AST/Expr.cpp
clang/unittests/AST/ASTTraverserTest.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index b9b7ca95b218..4c175fff6421 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -2909,7 +2909,8 @@ Expr *Expr::IgnoreUnlessSpelledInSource() {
   Expr *LastE = nullptr;
   while (E != LastE) {
 LastE = E;
-E = IgnoreExprNodes(E, IgnoreImplicitSingleStep, 
IgnoreImpCastsExtraSingleStep,
+E = IgnoreExprNodes(E, IgnoreImplicitSingleStep,
+IgnoreImpCastsExtraSingleStep,
 IgnoreParensOnlySingleStep);
 
 auto SR = E->getSourceRange();

diff  --git a/clang/unittests/AST/ASTTraverserTest.cpp 
b/clang/unittests/AST/ASTTraverserTest.cpp
index affbbe76f0d2..5585238939fe 100644
--- a/clang/unittests/AST/ASTTraverserTest.cpp
+++ b/clang/unittests/AST/ASTTraverserTest.cpp
@@ -291,6 +291,13 @@ void conversionOperator()
 C1 c1 = (*c2);
 }
 
+template 
+void template_test() {
+  static_assert(alignment, "");
+}
+void actual_template_test() {
+  template_test<4>();
+}
 )cpp");
 
   {
@@ -408,6 +415,31 @@ VarDecl 'c1'
 VarDecl 'c1'
 `-UnaryOperator
   `-DeclRefExpr 'c2'
+)cpp");
+  }
+
+  {
+auto FN = ast_matchers::match(
+functionDecl(hasName("template_test"),
+ hasDescendant(staticAssertDecl().bind("staticAssert"))),
+AST->getASTContext());
+EXPECT_EQ(FN.size(), 2u);
+
+EXPECT_EQ(dumpASTString(TK_AsIs, FN[1].getNodeAs("staticAssert")),
+  R"cpp(
+StaticAssertDecl
+|-ImplicitCastExpr
+| `-SubstNonTypeTemplateParmExpr
+|   `-IntegerLiteral
+`-StringLiteral
+)cpp");
+
+EXPECT_EQ(dumpASTString(TK_IgnoreUnlessSpelledInSource,
+FN[1].getNodeAs("staticAssert")),
+  R"cpp(
+StaticAssertDecl
+|-IntegerLiteral
+`-StringLiteral
 )cpp");
   }
 }

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
index e8b0a312d0a3..6bd8fcf66498 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1867,6 +1867,26 @@ void conversionOperator()
 hasDescendant(varDecl(
 hasName("c1"), hasInitializer(unaryOperator(

hasOperatorName("*");
+
+  Code = R"cpp(
+
+template 
+void template_test() {
+  static_assert(alignment, "");
+}
+void actual_template_test() {
+  template_test<4>();
+}
+
+)cpp";
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_AsIs,
+   staticAssertDecl(has(implicitCastExpr(has(
+   substNonTypeTemplateParmExpr(has(integerLiteral());
+
+  EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource,
+ 
staticAssertDecl(has(integerLiteral());
 }
 
 template 



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


[clang-tools-extra] 2be92b7 - Fix ignore-traversal to call correct method

2020-05-25 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2020-05-24T22:33:10+01:00
New Revision: 2be92b7f7e41037e051096df8a9c4de35502c036

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

LOG: Fix ignore-traversal to call correct method

As is done by ignoreParenImpCasts(). We were not previously calling the
correct internal method.  Adjust tests to account for this.

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
clang/lib/AST/Expr.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
index 70d2a10ae2d8..aab45faa6cb3 100644
--- a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
@@ -196,12 +196,12 @@ void 
UppercaseLiteralSuffixCheck::registerMatchers(MatchFinder *Finder) {
   // Sadly, we can't check whether the literal has suffix or not.
   // E.g. i32 suffix still results in 'BuiltinType::Kind::Int'.
   // And such an info is not stored in the *Literal itself.
-  Finder->addMatcher(
+  Finder->addMatcher(traverse(TK_AsIs,
   stmt(eachOf(integerLiteral().bind(IntegerLiteralCheck::Name),
   floatLiteral().bind(FloatingLiteralCheck::Name)),
unless(anyOf(hasParent(userDefinedLiteral()),
 hasAncestor(isImplicit()),
-hasAncestor(substNonTypeTemplateParmExpr(),
+hasAncestor(substNonTypeTemplateParmExpr()),
   this);
 }
 

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 0184140ab07e..b9b7ca95b218 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -2909,7 +2909,7 @@ Expr *Expr::IgnoreUnlessSpelledInSource() {
   Expr *LastE = nullptr;
   while (E != LastE) {
 LastE = E;
-E = IgnoreExprNodes(E, IgnoreImplicitSingleStep, IgnoreImpCastsSingleStep,
+E = IgnoreExprNodes(E, IgnoreImplicitSingleStep, 
IgnoreImpCastsExtraSingleStep,
 IgnoreParensOnlySingleStep);
 
 auto SR = E->getSourceRange();

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index d38086616460..82a28d00cebf 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -303,11 +303,13 @@ TEST(Matcher, SubstNonTypeTemplateParm) {
   EXPECT_FALSE(matches("template\n"
  "struct A {  static const int n = 0; };\n"
  "struct B : public A<42> {};",
-   substNonTypeTemplateParmExpr()));
+ traverse(TK_AsIs,
+   substNonTypeTemplateParmExpr(;
   EXPECT_TRUE(matches("template\n"
 "struct A {  static const int n = N; };\n"
 "struct B : public A<42> {};",
-  substNonTypeTemplateParmExpr()));
+ traverse(TK_AsIs,
+  substNonTypeTemplateParmExpr(;
 }
 
 TEST(Matcher, NonTypeTemplateParmDecl) {



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


[PATCH] D80472: [clangd] Add access specifier information to hover contents

2020-05-25 Thread Daniel Martín via Phabricator via cfe-commits
danielmartin updated this revision to Diff 265942.
danielmartin added a comment.

Move clang::getAccess to Specifiers.h and refactor logic in clang-doc
to use that function instead of its own.

Also changes where "public", "private" etc. is shown in the hover
contents. Now it's shown at the bottom.

Strengthens an existing unit test to also check for access specifiers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80472

Files:
  clang-tools-extra/clang-doc/Generators.cpp
  clang-tools-extra/clang-doc/Generators.h
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang/include/clang/Basic/Specifiers.h

Index: clang/include/clang/Basic/Specifiers.h
===
--- clang/include/clang/Basic/Specifiers.h
+++ clang/include/clang/Basic/Specifiers.h
@@ -365,6 +365,20 @@
   };
 
   llvm::StringRef getParameterABISpelling(ParameterABI kind);
+
+  inline llvm::StringRef getAccess(AccessSpecifier AS) {
+switch (AS) {
+case AccessSpecifier::AS_public:
+  return "public";
+case AccessSpecifier::AS_protected:
+  return "protected";
+case AccessSpecifier::AS_private:
+  return "private";
+case AccessSpecifier::AS_none:
+  return {};
+}
+llvm_unreachable("Unknown AccessSpecifier");
+  }
 } // end namespace clang
 
 #endif // LLVM_CLANG_BASIC_SPECIFIERS_H
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -80,6 +80,7 @@
  HI.Type = "char";
  HI.Offset = 0;
  HI.Size = 1;
+ HI.AccessSpecifier = "public";
}},
   // Local to class method.
   {R"cpp(
@@ -116,6 +117,7 @@
  HI.Type = "char";
  HI.Offset = 0;
  HI.Size = 1;
+ HI.AccessSpecifier = "public";
}},
   // Struct definition shows size.
   {R"cpp(
@@ -345,6 +347,7 @@
  HI.Kind = index::SymbolKind::Constructor;
  HI.Definition = "X()";
  HI.Parameters.emplace();
+ HI.AccessSpecifier = "public";
}},
   {"class X { [[^~]]X(); };", // FIXME: Should be [[~X]]()
[](HoverInfo ) {
@@ -354,6 +357,7 @@
  HI.Kind = index::SymbolKind::Destructor;
  HI.Definition = "~X()";
  HI.Parameters.emplace();
+ HI.AccessSpecifier = "private";
}},
   {"class X { [[op^erator]] int(); };",
[](HoverInfo ) {
@@ -363,6 +367,7 @@
  HI.Kind = index::SymbolKind::ConversionFunction;
  HI.Definition = "operator int()";
  HI.Parameters.emplace();
+ HI.AccessSpecifier = "private";
}},
   {"class X { operator [[^X]](); };",
[](HoverInfo ) {
@@ -495,6 +500,7 @@
  HI.NamespaceScope = "";
  HI.LocalScope = "Add<1, 2>::";
  HI.Value = "3";
+ HI.AccessSpecifier = "public";
}},
   {R"cpp(
 constexpr int answer() { return 40 + 2; }
@@ -607,6 +613,7 @@
  HI.Definition = "typename T = int";
  HI.LocalScope = "foo::";
  HI.Type = "typename";
+ HI.AccessSpecifier = "public";
}},
   {// TemplateTemplate Type Parameter
R"cpp(
@@ -619,6 +626,7 @@
  HI.Definition = "template  class T";
  HI.LocalScope = "foo::";
  HI.Type = "template  class";
+ HI.AccessSpecifier = "public";
}},
   {// NonType Template Parameter
R"cpp(
@@ -631,6 +639,7 @@
  HI.Definition = "int T = 5";
  HI.LocalScope = "foo::";
  HI.Type = "int";
+ HI.AccessSpecifier = "public";
}},
 
   {// Getter
@@ -647,6 +656,7 @@
  HI.Type = "float ()";
  HI.ReturnType = "float";
  HI.Parameters.emplace();
+ HI.AccessSpecifier = "public";
}},
   {// Setter
R"cpp(
@@ -665,6 +675,7 @@
  HI.Parameters->emplace_back();
  HI.Parameters->back().Type = "float";
  HI.Parameters->back().Name = "v";
+ HI.AccessSpecifier = "public";
}},
   {// Setter (builder)
R"cpp(
@@ -683,6 +694,7 @@
  HI.Parameters->emplace_back();
  HI.Parameters->back().Type = "float";
  HI.Parameters->back().Name = "v";
+ HI.AccessSpecifier = "public";
}},
   };
   for (const auto  : Cases) {
@@ -716,6 +728,7 @@
 EXPECT_EQ(H->Value, Expected.Value);
 EXPECT_EQ(H->Size, Expected.Size);
 EXPECT_EQ(H->Offset, Expected.Offset);
+EXPECT_EQ(H->AccessSpecifier, Expected.AccessSpecifier);
   }
 }
 
@@ -1968,20 +1981,20 @@
   {
   [](HoverInfo ) {
 

[PATCH] D79437: [clang-tidy] Add fsetpos argument checker

2020-05-25 Thread Beka Grdzelishvili via Phabricator via cfe-commits
DerWaschbar added a comment.

In D79437#2052109 , @aaron.ballman 
wrote:

> Thank you for working on this check, I think it's useful functionality. One 
> concern I have, though, is that it's not flow-sensitive and should probably 
> be implemented as a clang static analyzer check instead of a clang-tidy 
> check. For instance, consider these three plausible issues:
>
>   // This only sets the offset on one code path.
>   void func(FILE *fp) {
> fpos_t offset;
> if (condition) {
>   // ... code
>   if (0 != fgetpos(fp, ))
> return;
>   // ... code
> } else {
>  // ... code
> }
> fsetpos(fp, );
>   }
>  
>   // This doesn't check the failure from getting the position and sets the 
> position regardless.
>   void func(FILE *fp) {
> fpos_t offset;
> fgetpos(fp, );
> // ... code
> fsetpos(fp, );
>   }
>  
>   // This function accepts the offset from the caller but the caller passes 
> an invalid offset.
>   void func(FILE *fp, const fpos_t *offset) {
> fsetpos(fp, offset);
>   }
>   void caller(FILE *fp) {
> fpos_t offset;
> func(fp, );
>   }
>
>
> Have you considered writing a static analyzer check so you can do data and 
> control flow analysis to catch issues like these?


I have noticed those issues too, but most likely the getter/setter will be in 
the same function body and we could measure fast how common is that issue in 
the wild. Also, this was my first introductory project for Clang and with that, 
I can rewrite this as a Static Analyzer project or start working on another 
Clang-Tidy project.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D79437



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


[PATCH] D79912: Assignment and Inc/Dec operators wouldn't register as a mutation when Implicit Paren Casts were present

2020-05-25 Thread Joe Burzinski via Phabricator via cfe-commits
Tridacnid added a comment.

Ping


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

https://reviews.llvm.org/D79912



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


[PATCH] D79437: [clang-tidy] Add fsetpos argument checker

2020-05-25 Thread Beka Grdzelishvili via Phabricator via cfe-commits
DerWaschbar updated this revision to Diff 265930.
DerWaschbar marked 3 inline comments as done.

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D79437

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/FsetposArgumentCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/FsetposArgumentCheck.h
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-fsetpos-argument-check.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-fio44-c.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-fsetpos-argument-check.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-fsetpos-argument-check.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-fsetpos-argument-check.cpp
@@ -0,0 +1,59 @@
+// RUN: %check_clang_tidy %s bugprone-fsetpos-argument-check %t
+
+typedef unsigned int size_t;
+class FILE;
+struct fpos_t {};
+int fsetpos(FILE *stream, const fpos_t *pos);
+int fgetpos(FILE *stream, fpos_t *pos);
+void *memset(void *ptr, int value, size_t num);
+
+//-
+
+int opener1(FILE *file) {
+  int rc;
+  fpos_t offset;
+
+  if (file == nullptr ) {
+return -1;
+  }
+
+  rc = fgetpos(file, );
+  if (rc != 0 ) {
+return rc;
+  }
+
+  /* Read in data from file */
+
+  rc = fsetpos(file, );
+  if (rc != 0 ) {
+return rc;
+  }
+
+  return 0;
+}
+
+//-
+
+int opener2(FILE *file) {
+  int rc;
+  fpos_t offset;
+
+  memset(, 0, sizeof(offset));
+
+  if (file == nullptr) {
+return -1;
+  }
+
+  /* Read in data from file */
+
+  rc = fsetpos(file, );
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: file position indicator should be obtained only from 'fgetpos' [bugprone-fsetpos-argument-check]
+  if (rc != 0 ) {
+return rc;
+  }
+
+  return 0;
+}
+
+
+//-
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -57,6 +57,7 @@
`bugprone-fold-init-type `_,
`bugprone-forward-declaration-namespace `_,
`bugprone-forwarding-reference-overload `_,
+   `bugprone-fsetpos-argument-check ` _,
`bugprone-inaccurate-erase `_, "Yes"
`bugprone-incorrect-roundings `_,
`bugprone-infinite-loop `_,
@@ -315,6 +316,7 @@
`cert-err09-cpp `_, `misc-throw-by-value-catch-by-reference `_,
`cert-err61-cpp `_, `misc-throw-by-value-catch-by-reference `_,
`cert-fio38-c `_, `misc-non-copyable-objects `_,
+   `cert-fio44-c `_, `bugprone-fsetpos-argument-check `_,
`cert-msc30-c `_, `cert-msc50-cpp `_,
`cert-msc32-c `_, `cert-msc51-cpp `_,
`cert-oop11-cpp `_, `performance-move-constructor-init `_, "Yes"
Index: clang-tools-extra/docs/clang-tidy/checks/cert-fio44-c.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cert-fio44-c.rst
@@ -0,0 +1,10 @@
+.. title:: clang-tidy - cert-fio44-c
+.. meta::
+   :http-equiv=refresh: 5;URL=bugprone-fsetpos-argument-check.html
+
+cert-fio44-c
+
+
+The cert-fio44-c check is an alias, please see
+`bugprone-fsetpos-argument-check `_
+for more information.
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-fsetpos-argument-check.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-fsetpos-argument-check.rst
@@ -0,0 +1,37 @@
+.. title:: clang-tidy - bugprone-fsetpos-argument-check
+
+bugprone-fsetpos-argument-check
+===
+
+Finds call of ``fsetpos`` functions, which does not have file position indicator
+obtained from ``fgetpos``.
+
+.. code-block:: c
+
+#include 
+#include 
+
+int opener(FILE *file) {
+int rc;
+fpos_t offset;
+
+memset(, 0, sizeof(offset));
+
+if (file == NULL) {
+return -1;
+}
+
+/* Read in data from file */
+
+rc = fsetpos(file, );
+if (rc != 0 ) {
+return rc;
+}
+
+return 0;
+}
+
+
+This check corresponds to the CERT C Coding Standard rule
+`FIO44-C. Only use values for fsetpos() that are returned from fgetpos()
+`_.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- 

[PATCH] D80492: Avoid linking libdl unless needed

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

I think this is ok, but adding @beanz who knows the cmake conventions better 
than me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80492



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


[PATCH] D80492: Avoid linking libdl unless needed

2020-05-25 Thread Tobias Hieta via Phabricator via cfe-commits
thieta created this revision.
thieta added a reviewer: mstorsjo.
thieta added a project: clang.
Herald added subscribers: cfe-commits, mgorny.

This fixes cross-compilation when targeting a platform not using libdl and 
mirrors libdl linking in other parts of the code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80492

Files:
  clang/tools/libclang/CMakeLists.txt


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -66,9 +66,8 @@
   endif ()
 endif ()
 
-find_library(DL_LIBRARY_PATH dl)
-if (DL_LIBRARY_PATH)
-  list(APPEND LIBS dl)
+if (HAVE_LIBDL)
+  list(APPEND LIBS ${CMAKE_DL_LIBS})
 endif()
 
 option(LIBCLANG_BUILD_STATIC


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -66,9 +66,8 @@
   endif ()
 endif ()
 
-find_library(DL_LIBRARY_PATH dl)
-if (DL_LIBRARY_PATH)
-  list(APPEND LIBS dl)
+if (HAVE_LIBDL)
+  list(APPEND LIBS ${CMAKE_DL_LIBS})
 endif()
 
 option(LIBCLANG_BUILD_STATIC
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80425: Fix LLVM/Clang builds with mingw toolchain

2020-05-25 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Sounds good - I'll close this one and open three new ones.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80425



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


[PATCH] D71155: [analyzer] CERT STR rule checkers: STR30-C

2020-05-25 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D71155#1854908 , @NoQ wrote:

> Let's separate `CStringChecker` improvements into a separate patch and have a 
> separate set of tests for it.


I was thinking about creating tests, but I cannot figure out any better testing 
than a live checker that uses such features of `CStringChecker`. Also I have 
not found any real world issues with the checker, so I could not really test 
its real behavior.


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

https://reviews.llvm.org/D71155



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


[PATCH] D70805: [analyzer] SValHasDescendant: Determine whether the SVal has an SVal descendant

2020-05-25 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso abandoned this revision.
Charusso added a comment.
Herald added subscribers: ASDenysPetrov, martong, steakhal.

Way more sophisticated matching: https://reviews.llvm.org/D77745


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

https://reviews.llvm.org/D70805



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


[PATCH] D80440: [OpenCL] Prevent fused mul and add by default

2020-05-25 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Contraction is just an optimization technique. Unless a user explicitly 
requests strict FP semantics, contraction does not break C++ semantics.


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

https://reviews.llvm.org/D80440



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


[PATCH] D70411: [analyzer] CERT STR rule checkers: STR31-C

2020-05-25 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 265959.
Charusso retitled this revision from "[analyzer] CERT: STR31-C" to "[analyzer] 
CERT STR rule checkers: STR31-C".
Charusso added a comment.

- Refactor.


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

https://reviews.llvm.org/D70411

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/AllocationState.h
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/cert/str31-c-false-positive-suppression.cpp
  clang/test/Analysis/cert/str31-c-notes.cpp
  clang/test/Analysis/cert/str31-c.cpp

Index: clang/test/Analysis/cert/str31-c.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/str31-c.cpp
@@ -0,0 +1,184 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,alpha.security.cert.str.31c \
+// RUN:  -verify %s
+
+// See the examples on the page of STR31-C:
+// https://wiki.sei.cmu.edu/confluence/x/sNUxBQ
+
+#include "../Inputs/system-header-simulator.h"
+
+typedef __SIZE_TYPE__ size_t;
+
+void free(void *memblock);
+void *malloc(size_t size);
+
+namespace test_gets_bad {
+#define BUFFER_SIZE 1024
+
+void func(void) {
+  char buf[BUFFER_SIZE];
+  if (gets(buf)) {
+// expected-warning@-1 {{'gets' could write outside of 'buf'}}
+  }
+}
+} // namespace test_gets_bad
+
+namespace test_gets_good {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buff[BUFFERSIZE];
+
+  if (fgets(buff, sizeof(buff), stdin)) {
+  }
+}
+} // namespace test_gets_good
+
+namespace test_sprintf_bad {
+void func(const char *name) {
+  char buf[128];
+  sprintf(buf, "%s.txt", name);
+  // expected-warning@-1 {{'sprintf' could write outside of 'buf'}}
+}
+} // namespace test_sprintf_bad
+
+namespace test_sprintf_good {
+void func(const char *name) {
+  char buff[128];
+  snprintf(buff, sizeof(buff), "%s.txt", name);
+}
+} // namespace test_sprintf_good
+
+namespace test_fscanf_bad {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buf[BUF_LENGTH];
+  fscanf(stdin, "%s", buf);
+  // expected-warning@-1 {{'fscanf' could write outside of 'buf'}}
+}
+} // namespace test_fscanf_bad
+
+namespace test_fscanf_good {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buff[BUF_LENGTH];
+  fscanf(stdin, "%1023s", buff);
+}
+} // namespace test_fscanf_good
+
+namespace test_strcpy_bad {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char prog_name[128];
+  strcpy(prog_name, name);
+  // expected-warning@-1 {{'strcpy' could write outside of 'prog_name'}}
+  return 0;
+}
+
+void func(void) {
+  char buff[256];
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+strcpy(buff, editor);
+// expected-warning@-1 {{'strcpy' could write outside of 'buff'}}
+  }
+}
+} // namespace test_strcpy_bad
+
+namespace test_strcpy_good {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char *prog_name2 = (char *)malloc(strlen(name) + 1);
+  if (prog_name2 != NULL) {
+strcpy(prog_name2, name);
+  }
+
+  free(prog_name2);
+  return 0;
+}
+
+void func(void) {
+  char *buff2;
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+size_t len = strlen(editor) + 1;
+buff2 = (char *)malloc(len);
+if (buff2 != NULL) {
+  strcpy(buff2, editor);
+}
+
+free(buff2);
+  }
+}
+} // namespace test_strcpy_good
+
+//===--===//
+// The following are from the rule's page which we do not handle yet.
+//===--===//
+
+namespace test_loop_index_bad {
+void copy(size_t n, char src[n], char dest[n]) {
+  size_t i;
+
+  for (i = 0; src[i] && (i < n); ++i) {
+dest[i] = src[i];
+  }
+  dest[i] = '\0';
+}
+} // namespace test_loop_index_bad
+
+namespace test_loop_index_good {
+void copy(size_t n, char src[n], char dest[n]) {
+  size_t i;
+
+  for (i = 0; src[i] && (i < n - 1); ++i) {
+dest[i] = src[i];
+  }
+  dest[i] = '\0';
+}
+} // namespace test_loop_index_good
+
+namespace test_getchar_bad {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buf[BUFFERSIZE];
+  char *p;
+  int ch;
+  p = buf;
+  while ((ch = getchar()) != '\n' && ch != EOF) {
+*p++ = (char)ch;
+  }
+  *p++ = 0;
+  if (ch == EOF) {
+/* Handle EOF or error */
+  }
+}
+} // namespace test_getchar_bad
+
+namespace test_getchar_good {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buf[BUFFERSIZE];
+  int ch;
+  size_t index = 0;
+  size_t chars_read = 0;
+
+  while ((ch = getchar()) != '\n' && ch != EOF) {
+if (index < sizeof(buf) - 1) {
+  buf[index++] = (char)ch;
+}
+ 

[PATCH] D71155: [analyzer] CERT STR rule checkers: STR30-C

2020-05-25 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 265963.
Charusso retitled this revision from "[analyzer] CERT: STR30-C" to "[analyzer] 
CERT STR rule checkers: STR30-C".
Charusso added a comment.
Herald added subscribers: ASDenysPetrov, martong, steakhal.

- Refactor.


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

https://reviews.llvm.org/D71155

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
  clang/test/Analysis/cert/str30-c-notes.cpp
  clang/test/Analysis/cert/str30-c.cpp

Index: clang/test/Analysis/cert/str30-c.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/str30-c.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,alpha.security.cert.str.30c \
+// RUN:  -verify %s
+
+// See the examples on the page of STR30-C:
+// https://wiki.sei.cmu.edu/confluence/x/VtYxBQ
+
+#include "../Inputs/system-header-simulator.h"
+
+typedef __SIZE_TYPE__ size_t;
+typedef __typeof__((char *)0 - (char *)0) ptrdiff_t;
+
+void free(void *memblock);
+void *malloc(size_t size);
+
+char *strrchr(const char *str, int c);
+int puts(const char *str);
+
+namespace test_strrchr_bad {
+const char *get_dirname(const char *pathname) {
+  char *slash;
+  slash = strrchr(pathname, '/');
+  if (slash) {
+*slash = '\0'; /* Undefined behavior */
+// expected-warning@-1 {{'*slash' is pointing to a constant string}}
+  }
+  return pathname;
+}
+
+int main(void) {
+  puts(get_dirname(__FILE__));
+  return 0;
+}
+} // namespace test_strrchr_bad
+
+namespace test_strrchr_good {
+char *get_dirname(const char *pathname, char *dirname, size_t size) {
+  const char *slash;
+  slash = strrchr(pathname, '/');
+  if (slash) {
+ptrdiff_t slash_idx = slash - pathname;
+if ((size_t)slash_idx < size) {
+  memcpy(dirname, pathname, slash_idx);
+  dirname[slash_idx] = '\0';
+  return dirname;
+}
+  }
+  return 0;
+}
+
+int main(void) {
+  char dirname[260];
+  if (get_dirname(__FILE__, dirname, sizeof(dirname))) {
+puts(dirname);
+  }
+  return 0;
+}
+} // namespace test_strrchr_good
Index: clang/test/Analysis/cert/str30-c-notes.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/str30-c-notes.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,alpha.security.cert.str.30c \
+// RUN:  -analyzer-output=text -verify %s
+
+// See the examples on the page of STR30-C:
+// https://wiki.sei.cmu.edu/confluence/x/VtYxBQ
+
+#include "../Inputs/system-header-simulator.h"
+
+typedef __SIZE_TYPE__ size_t;
+
+void free(void *memblock);
+void *malloc(size_t size);
+
+char *strrchr(const char *str, int c);
+int puts(const char *str);
+
+namespace test_strrchr_bad {
+const char *get_dirname(const char *pathname) {
+  char *slash;
+  slash = strrchr(pathname, '/');
+  // expected-note@-1 {{'strrchr' returns a pointer to the constant 'pathname'}}
+
+  slash = strrchr(slash, '/');
+  // expected-note@-1 {{'strrchr' returns a pointer to the constant 'slash'}}
+
+  if (slash) {
+// expected-note@-1 {{'slash' is non-null}}
+// expected-note@-2 {{Taking true branch}}
+
+*slash = '\0'; /* Undefined behavior */
+// expected-note@-1 {{'*slash' is pointing to a constant string}}
+// expected-warning@-2 {{'*slash' is pointing to a constant string}}
+  }
+  return pathname;
+}
+
+int main(void) {
+  puts(get_dirname(__FILE__));
+  // expected-note@-1 {{Calling 'get_dirname'}}
+  return 0;
+}
+} // namespace test_strrchr_bad
Index: clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
@@ -12,6 +12,9 @@
 // - https://wiki.sei.cmu.edu/confluence/x/ptUxBQ
 //
 //  This checker is a base checker which consist of the following checkers:
+//  - STR30-C: Do not attempt to modify string literals:
+// - https://wiki.sei.cmu.edu/confluence/x/VtYxBQ
+//
 //  - STR31-C: Guarantee that storage for strings has sufficient space for
 //character data and the null terminator:
 // - https://wiki.sei.cmu.edu/confluence/x/sNUxBQ
@@ -83,6 +86,17 @@
 
   /// \{
   /// Check the function calls defined in 'CDM'.
+  /// STR30-C.
+  void checkMemchr(const CallEvent , const CallContext ,
+   CheckerContext ) const;
+  void checkStrchr(const CallEvent , const CallContext ,
+   CheckerContext ) const;
+  void checkStrrchr(const CallEvent , const CallContext ,
+CheckerContext ) const;
+  void checkStrstr(const CallEvent , const CallContext ,
+   CheckerContext ) const;
+  void checkStrpbrk(const CallEvent , const CallContext ,
+ 

[PATCH] D71033: [analyzer] CERT STR rule checkers: STR32-C

2020-05-25 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 265962.
Charusso retitled this revision from "[analyzer] CERT: STR32-C" to "[analyzer] 
CERT STR rule checkers: STR32-C".
Charusso added a comment.
Herald added subscribers: ASDenysPetrov, martong, steakhal.

- Refactor.
- State out explicitly whether the Analyzer models the dynamic size.


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

https://reviews.llvm.org/D71033

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/cert/str32-c-notes.cpp
  clang/test/Analysis/cert/str32-c.cpp
  clang/test/Analysis/malloc.c

Index: clang/test/Analysis/malloc.c
===
--- clang/test/Analysis/malloc.c
+++ clang/test/Analysis/malloc.c
@@ -9,21 +9,6 @@
 
 void clang_analyzer_eval(int);
 
-// Without -fms-compatibility, wchar_t isn't a builtin type. MSVC defines
-// _WCHAR_T_DEFINED if wchar_t is available. Microsoft recommends that you use
-// the builtin type: "Using the typedef version can cause portability
-// problems", but we're ok here because we're not actually running anything.
-// Also of note is this cryptic warning: "The wchar_t type is not supported
-// when you compile C code".
-//
-// See the docs for more:
-// https://msdn.microsoft.com/en-us/library/dh8che7s.aspx
-#if !defined(_WCHAR_T_DEFINED)
-// "Microsoft implements wchar_t as a two-byte unsigned value"
-typedef unsigned short wchar_t;
-#define _WCHAR_T_DEFINED
-#endif // !defined(_WCHAR_T_DEFINED)
-
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
 void *alloca(size_t);
Index: clang/test/Analysis/cert/str32-c.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/str32-c.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,alpha.security.cert.str.32c \
+// RUN:  -verify %s
+
+// See the examples on the page of STR32-C:
+// https://wiki.sei.cmu.edu/confluence/x/r9UxBQ
+
+#include "../Inputs/system-header-simulator.h"
+
+void *realloc(void *memblock, size_t size);
+
+namespace test_strncpy_bad {
+enum { STR_SIZE = 32 };
+
+size_t func(const char *source) {
+  char c_str[STR_SIZE];
+  size_t ret = 0;
+
+  if (source) {
+c_str[sizeof(c_str) - 1] = '\0';
+strncpy(c_str, source, sizeof(c_str));
+ret = strlen(c_str);
+// expected-warning@-1 {{'c_str' is not null-terminated}}
+  }
+  return ret;
+}
+} // namespace test_strncpy_bad
+
+namespace test_strncpy_good {
+enum { STR_SIZE = 32 };
+
+size_t func(const char *src) {
+  char c_str[STR_SIZE];
+  size_t ret = 0;
+
+  if (src) {
+strncpy(c_str, src, sizeof(c_str) - 1);
+c_str[sizeof(c_str) - 1] = '\0';
+ret = strlen(c_str);
+  }
+  return ret;
+}
+} // namespace test_strncpy_good
+
+namespace test_realloc_bad {
+wchar_t *cur_msg = NULL;
+size_t cur_msg_size = 1024;
+size_t cur_msg_len = 0;
+
+void lessen_memory_usage(void) {
+  if (cur_msg == NULL)
+return;
+
+  size_t temp_size = cur_msg_size / 2 + 1;
+  wchar_t *temp = (wchar_t *)realloc(cur_msg, temp_size * sizeof(wchar_t));
+  /* temp and cur_msg may no longer be null-terminated */
+  if (temp == NULL)
+return;
+
+  cur_msg = temp;
+  cur_msg_size = temp_size;
+  cur_msg_len = wcslen(cur_msg);
+  // expected-warning@-1 {{'cur_msg' is not null-terminated}}
+}
+} // namespace test_realloc_bad
+
+namespace test_realloc_good {
+wchar_t *cur_msg = NULL;
+size_t cur_msg_size = 1024;
+size_t cur_msg_len = 0;
+
+void lessen_memory_usage(void) {
+  if (cur_msg == NULL)
+return;
+
+  size_t temp_size = cur_msg_size / 2 + 1;
+  wchar_t *temp = (wchar_t *)realloc(cur_msg, temp_size * sizeof(wchar_t));
+  /* temp and cur_msg may no longer be null-terminated */
+  if (temp == NULL)
+return;
+
+  cur_msg = temp;
+  /* Properly null-terminate cur_msg */
+  cur_msg[temp_size - 1] = L'\0';
+  cur_msg_size = temp_size;
+  cur_msg_len = wcslen(cur_msg);
+}
+} // namespace test_realloc_good
Index: clang/test/Analysis/cert/str32-c-notes.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/str32-c-notes.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,alpha.security.cert.str.32c \
+// RUN:  -analyzer-output=text -verify %s
+
+// See the examples on the page of STR32-C:
+// https://wiki.sei.cmu.edu/confluence/x/r9UxBQ
+
+#include "../Inputs/system-header-simulator.h"
+
+void *realloc(void *memblock, size_t size);
+
+namespace test_realloc_bad {
+size_t cur_msg_size = 1024;
+size_t cur_msg_len = 0;
+
+void lessen_memory_usage(wchar_t *cur_msg) {
+  if (cur_msg == NULL) {
+// expected-note@-1 {{Assuming 'cur_msg' is 

[PATCH] D80144: [clang-format] @lefticus just taught the world how to use [[unlikely]] but we forgot to teach clang-format

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



> I know that we didn't have a test for this in ObjC land, but the regression 
> seems severe enough to revert this

Sure go ahead, that's the process.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80144



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


[PATCH] D80514: [clang-tidy] modernize-use-trailing-return-type support for C++20 concepts and decltype

2020-05-25 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type.cpp:550
+
+#if __cplusplus > 201703L /* C++2a and later */
+

bernhardmgruber wrote:
> How do you want to handle these tests which require C++20? I have seen other 
> checks use a separate file for tests which require a different language 
> version.
Yes, move them into a seperate file and specify `-std=c++20` in the run line


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

https://reviews.llvm.org/D80514



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


[PATCH] D80296: [clangd] Don't traverse the AST within uninteresting files during indexing

2020-05-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 266059.
sammccall marked an inline comment as done.
sammccall added a comment.

Tweak names, style, comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80296

Files:
  clang-tools-extra/clangd/index/IndexAction.cpp
  clang-tools-extra/clangd/unittests/IndexActionTests.cpp
  clang/include/clang/Index/IndexingAction.h
  clang/include/clang/Index/IndexingOptions.h
  clang/lib/Index/IndexDecl.cpp
  clang/lib/Index/IndexingAction.cpp

Index: clang/lib/Index/IndexingAction.cpp
===
--- clang/lib/Index/IndexingAction.cpp
+++ clang/lib/Index/IndexingAction.cpp
@@ -131,6 +131,21 @@
 ShouldSkipFunctionBody);
 }
 
+std::unique_ptr clang::index::createIndexingASTConsumer(
+std::shared_ptr DataConsumer,
+const IndexingOptions , std::shared_ptr PP) {
+  std::function ShouldSkipFunctionBody = [](const Decl *) {
+return false;
+  };
+  if (Opts.ShouldTraverseDecl)
+ShouldSkipFunctionBody =
+[ShouldTraverseDecl(Opts.ShouldTraverseDecl)](const Decl *D) {
+  return !ShouldTraverseDecl(D);
+};
+  return createIndexingASTConsumer(std::move(DataConsumer), Opts, std::move(PP),
+   std::move(ShouldSkipFunctionBody));
+}
+
 std::unique_ptr
 index::createIndexingAction(std::shared_ptr DataConsumer,
 const IndexingOptions ) {
Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -765,6 +765,9 @@
   if (isa(D))
 return true; // Wait for the objc container.
 
+  if (IndexOpts.ShouldTraverseDecl && !IndexOpts.ShouldTraverseDecl(D))
+return true; // skip
+
   return indexDecl(D);
 }
 
Index: clang/include/clang/Index/IndexingOptions.h
===
--- clang/include/clang/Index/IndexingOptions.h
+++ clang/include/clang/Index/IndexingOptions.h
@@ -34,6 +34,12 @@
   // Has no effect if IndexFunctionLocals are false.
   bool IndexParametersInDeclarations = false;
   bool IndexTemplateParameters = false;
+
+  // If set, skip indexing inside some declarations for performance.
+  // This prevents traversal, so skipping a struct means its declaration an
+  // members won't be indexed, but references elsewhere to that struct will be.
+  // Currently this is only checked for top-level declarations.
+  std::function ShouldTraverseDecl;
 };
 
 } // namespace index
Index: clang/include/clang/Index/IndexingAction.h
===
--- clang/include/clang/Index/IndexingAction.h
+++ clang/include/clang/Index/IndexingAction.h
@@ -30,22 +30,21 @@
 }
 
 namespace index {
-  class IndexDataConsumer;
+class IndexDataConsumer;
 
 /// Creates an ASTConsumer that indexes all symbols (macros and AST decls).
+std::unique_ptr
+createIndexingASTConsumer(std::shared_ptr DataConsumer,
+  const IndexingOptions ,
+  std::shared_ptr PP);
+
 std::unique_ptr createIndexingASTConsumer(
 std::shared_ptr DataConsumer,
 const IndexingOptions , std::shared_ptr PP,
+// Prefer to set Opts.ShouldTraverseDecl and use the above overload.
+// This version is only needed if used to *track* function body parsing.
 std::function ShouldSkipFunctionBody);
 
-inline std::unique_ptr createIndexingASTConsumer(
-std::shared_ptr DataConsumer,
-const IndexingOptions , std::shared_ptr PP) {
-  return createIndexingASTConsumer(
-  std::move(DataConsumer), Opts, std::move(PP),
-  /*ShouldSkipFunctionBody=*/[](const Decl *) { return false; });
-}
-
 /// Creates a frontend action that indexes all symbols (macros and AST decls).
 std::unique_ptr
 createIndexingAction(std::shared_ptr DataConsumer,
Index: clang-tools-extra/clangd/unittests/IndexActionTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexActionTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexActionTests.cpp
@@ -19,6 +19,7 @@
 
 using ::testing::AllOf;
 using ::testing::ElementsAre;
+using ::testing::EndsWith;
 using ::testing::Not;
 using ::testing::Pair;
 using ::testing::UnorderedElementsAre;
@@ -75,8 +76,7 @@
 new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
 auto Action = createStaticIndexingAction(
-SymbolCollector::Options(),
-[&](SymbolSlab S) { IndexFile.Symbols = std::move(S); },
+Opts, [&](SymbolSlab S) { IndexFile.Symbols = std::move(S); },
 [&](RefSlab R) { IndexFile.Refs = std::move(R); },
 [&](RelationSlab R) { IndexFile.Relations = std::move(R); },
 [&](IncludeGraph IG) { IndexFile.Sources = std::move(IG); });
@@ -99,11 +99,12 @@
 

[PATCH] D80525: [clangd] Fix crash-bug in preamble indexing when using modules.

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



Comment at: clang-tools-extra/clangd/test/symbols-modules.test:1
+# Verify that we do not crash and correctly find the definition of a macro that
+# was imported from a module and then #undef-ed in preamble.

Generally, we prefer to write tests as gunit tests where feasible, this gathers 
the inputs into one place, avoids too much messing around with the filesystem, 
and assertions on something a little simpler than the full JSON output. It also 
make it easier to factor out common bits across tests.

If I'm understanding this test right it should be fairly easy to port to a 
gunit test with `TestTU` (setting AdditionalFiles and ExtraArgs) which would 
assert on headerSymbols(). This would probably go in SymbolCollectorTests, 
similar to e.g. `TEST_F(SymbolCollectorTest, NonModularHeader)`.

Obviously this relates to where other tests around indexing modules might live 
once we have those. If you'd prefer them to be lit tests, it'd be nice to know 
a bit about that.



Comment at: clang/include/clang/Lex/Preprocessor.h:1126
+  return MI;
+MacroState  = CurSubmoduleState->Macros[II];
+auto ActiveModuleMacros = S.getActiveModuleMacros(*this, II);

This looks fairly grungy and I don't totally understand it :-(
I guess walking the getPrevious() chain on the macro definition until we hit 
one with info doesn't work?
If we can't reuse something existing for this, we should probably ask rsmith if 
this is sensible.

API quibbles:
 - it seems this only differs for modules, but the name doesn't mention modules
 - maybe this should just be a "bool LookIntoModules" in `getMacroInfo`? it has 
only 3 callers.



Comment at: clang/lib/Index/IndexingAction.cpp:155
+  auto *MI = MD->getMacroInfo();
+  if (!MI) {
+// It is possible for MI to be nullptr if we our translation unit had

You don't need to call getMacroInfo() here, getMacroInfoForLatestDefinition() 
does this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80525



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


[PATCH] D80296: [clangd] Don't traverse the AST within uninteresting files during indexing

2020-05-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 5 inline comments as done.
sammccall added a comment.

In D80296#2053189 , @adamcz wrote:

> Correct me if I'm wrong, but this might lead to a file never being updated in 
> the index, even after edit, right?
>  Let's say you have file a.cpp that includes a.h. a.h has
>  namespace foo {
>
>   #define EXPAND(foo) whatever
>   #include "b.h"
>
> }
>  all nodes from b.h will be inside the namespace node in a.h. If a.h did not 
> change, b.h will never be indexed.


Yes, there's some potential regression here. It exists if:

- the including file is unmodified, the included is modified
- the including file defines the top-level decl (e.g. enclosing namespaces), 
otherwise change has no effect
- the symbols are considered part of the included file for sharding purposes, 
otherwise this already didn't work. (I think they are in most cases)

I think I'm comfortable throwing this in the "clangd is designed for 
well-structured codebases" bucket, along with non-self-contained files in other 
contexts (b.h is necessarily not self-contained here). I'm also comfortable 
saying tablegen isn't a well-structured part of LLVM :-)
And for preamble index, (which doesn't yet have this optimization) I think 
that's the end of the story.
However, this being persistently sticky *forever* with the background index 
does seem pretty horrible. I can't see an elegant fix though, and a 33% speedup 
for background index is an important win (it's a top clangd complaint).

Any bright ideas? If not, maybe we land this and try to fix it somehow later, 
or just accept it as one of our speed/accuracy tradeoffs.




Comment at: clang-tools-extra/clangd/unittests/IndexActionTests.cpp:22
 using ::testing::ElementsAre;
+using testing::EndsWith;
 using ::testing::Not;

kadircet wrote:
> nit `using ::testing::EndsWith`
> 
> was this `add using` tweak ?
Yes, it was.
I feel a bit silly as I'm well aware of the behaviour here and have argued it's 
the right thing, and wrote `testing::EndsWith` inline, extracted it, and didn't 
check the output (as it was offscreen).

@adamcz FYI
If we see this a lot maybe we should consider something like "if all existing 
usings in the block are globally qualified...". Current behavior is definitely 
defensible though.



Comment at: clang/lib/Index/IndexingAction.cpp:142
+ShouldSkipFunctionBody =
+[ShouldTraverseDecl(Opts.ShouldTraverseDecl)](const Decl *D) {
+  return !ShouldTraverseDecl(D);

kadircet wrote:
> are we happy with the copy here ?
> 
> I am a little uneasy, as these functions can preserve state. Currently the 
> one used in here and the one used in `IndexingContext::indexTopLevelDecl` are 
> different copies.
> 
> Maybe rather progate a null function into the `IndexASTConsumer` and create 
> this default lambda in there, making use of the function inside 
> `IndexingContext::IndexOpts` without a copy?
> are we happy with the copy here ?

Note that we already have a copy: we take IndexingOptions by const ref and 
createIndexingASTConsumer copies it, including the function. So anything that 
relies on the identity of the function passed in, or breaks semantics of 
copying, is busted already.

as for internal state (e.g. a cache)... I'd agree if this were a heavily used 
library function (find a way to capture by pointer/shared_ptr). But it's not, 
and neither of the in-tree callers work this way - I'm not sure it's worth 
spending API complexity on.

> Maybe rather progate...

Hmm, I like the idea that these are clearly separate options at the lower 
internal layer, and that blurs the lines a bit.
(I'd like *more* making them completely the same, but halfway isn't a happy 
place to be I think)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80296



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


[PATCH] D80198: [clangd] locateMacroAt handles patched macros

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



Comment at: clang-tools-extra/clangd/Preamble.cpp:123
 
+// Spells directive in \p DirectiveRange while prepending it with \p Prefix.
+// Returned string can be used with a #line directive on line \p DirectiveLine

> Spells directive in \p DirectiveRange while prepending it with \p Prefix

I wouldn't understand what this meant if I didn't already know :-) Maybe:

```
// Formats a PP directive consisting of Prefix (e.g. "#define ") and Body ("X 
10").
// The formatting is copied so that the tokens in Body have PresumedLocs with
// correct columns and lines.
```



Comment at: clang-tools-extra/clangd/Preamble.cpp:127
+std::string spellDirective(llvm::StringRef Prefix, SourceRange DirectiveRange,
+   unsigned , const SourceManager ) {
+  std::string SpelledDirective;

nit: move out-param to end?



Comment at: clang-tools-extra/clangd/Preamble.cpp:133
+  auto DecompLoc = SM.getDecomposedLoc(DirectiveRange.getBegin());
+  DirectiveLine = SM.getLineNumber(DecompLoc.first, DecompLoc.second);
+  auto SpaceBefore = SM.getColumnNumber(DecompLoc.first, DecompLoc.second) - 1;

This is only going to give you something useful for file IDs, not macro 
expansions. Whose responsibility is it to make sure there's no macro IDs here?



Comment at: clang-tools-extra/clangd/Preamble.cpp:134
+  DirectiveLine = SM.getLineNumber(DecompLoc.first, DecompLoc.second);
+  auto SpaceBefore = SM.getColumnNumber(DecompLoc.first, DecompLoc.second) - 1;
+

this name seems a bit confusing to me, since it only covers one case.
TargetColumn?
`if (TargetColumn < Prefix.size())` reads a lot celarer I think.



Comment at: clang-tools-extra/clangd/Preamble.cpp:136
+
+  // Pad with spaces before DirectiveRange to make sure it will be on right
+  // column when patched.

again this comment only applyes to one branch



Comment at: clang-tools-extra/clangd/Preamble.cpp:139
+  if (SpaceBefore < Prefix.size()) {
+// Prefix was longer than the space we had. Pad from start of a new line.
+OS << "\\\n" << std::string(SpaceBefore, ' ');

Rather than "pad from the start of a new line" it might be clearer to give an 
example here:
```
... We produce e.g.:
#line N-1
#define \
   X 10
```



Comment at: clang-tools-extra/clangd/Preamble.cpp:149
+  }
+  OS << toSourceCode(SM, DirectiveRange);
+  return OS.str();

this asserts isValidFileRange, so we need this to be true :-)



Comment at: clang-tools-extra/clangd/SourceCode.cpp:976
+  // #line directives to hint their original location in main file.
+  auto DefFile = SM.getFileID(NameLoc);
+  auto IncludeLoc = SM.getIncludeLoc(DefFile);

I think this block can now be lifted to a function in SourceCode or Preamble or 
so?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80198



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


[PATCH] D79628: [Clang][Driver] Add Bounds and Thread to SupportsCoverage list

2020-05-25 Thread Marco Elver via Phabricator via cfe-commits
melver updated this revision to Diff 266057.
melver added a comment.

Add missing -target to sanitize-coverage-bounds test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79628

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/sanitize-coverage-bounds.c
  clang/test/CodeGen/sanitize-coverage-thread.c
  clang/test/Driver/fsanitize-coverage.c
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
  compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp
  compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp

Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp
@@ -1,7 +1,6 @@
 // Tests trace pc guard coverage collection.
 //
 // REQUIRES: has_sancovcc,stable-runtime,x86_64-linux
-// XFAIL: tsan
 //
 // RUN: DIR=%t_workdir
 // RUN: CLANG_ARGS="-O0 -fsanitize-coverage=trace-pc-guard"
Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp
@@ -1,7 +1,5 @@
 // Tests -fsanitize-coverage=stack-depth
 //
-// XFAIL: tsan
-//
 // RUN: %clangxx -O0 -std=c++11 -fsanitize-coverage=stack-depth %s -o %t
 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not Assertion{{.*}}failed
 // RUN: %clangxx -O0 -std=c++11 -fsanitize-coverage=trace-pc-guard,stack-depth \
Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp
@@ -2,7 +2,7 @@
 
 // REQUIRES: has_sancovcc,stable-runtime
 // UNSUPPORTED: i386-darwin
-// XFAIL: ubsan,tsan
+// XFAIL: ubsan
 // XFAIL: android && asan
 
 // RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=trace-pc,bb,no-prune 2>&1 | grep "call void @__sanitizer_cov_trace_pc" | count 3
Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
@@ -5,7 +5,6 @@
 //
 // RUN: %clangxx -O0 %s -fsanitize-coverage=inline-bool-flag,pc-table -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
-// XFAIL: tsan
 
 #include 
 #include 
Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp
@@ -5,7 +5,6 @@
 //
 // RUN: %clangxx -O0 %s -fsanitize-coverage=inline-8bit-counters,pc-table -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
-// XFAIL: tsan
 
 #include 
 #include 
Index: clang/test/Driver/fsanitize-coverage.c
===
--- clang/test/Driver/fsanitize-coverage.c
+++ clang/test/Driver/fsanitize-coverage.c
@@ -12,8 +12,10 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=kernel-memory -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=leak -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=bounds -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=bool -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=dataflow -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread 

[PATCH] D80514: [clang-tidy] modernize-use-trailing-return-type support for C++20 concepts and decltype

2020-05-25 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber updated this revision to Diff 266060.
bernhardmgruber added a comment.

moved C++20 tests to a new file


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

https://reviews.llvm.org/D80514

Files:
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/modernize-use-trailing-return-type.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type-cxx20.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++14,c++17 %s modernize-use-trailing-return-type %t -- -- -fdeclspec -fexceptions
+// RUN: %check_clang_tidy -std=c++14-or-later %s modernize-use-trailing-return-type %t -- -- -fdeclspec -fexceptions
 // FIXME: Fix the checker to work in C++2a mode, it is performing a
 // use-of-uninitialized-value.
 
@@ -11,6 +11,8 @@
 
 class string;
 
+class ostream;
+
 template 
 auto declval() -> T;
 }
@@ -215,18 +217,28 @@
 // CHECK-FIXES: {{^}}auto e13() -> struct A;{{$}}
 
 //
-// decltype (unsupported if top level expression)
+// deduced return types
 //
 
+const auto ded1();
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto ded1() -> const auto;{{$}}
+const auto& ded2();
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto ded2() -> const auto&;{{$}}
+
+decltype(auto) ded3();
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto ded3() -> decltype(auto);{{$}}
+
+
 decltype(1 + 2) dec1() { return 1 + 2; }
 // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// TODO: source range of DecltypeTypeLoc not yet implemented
-// _HECK-FIXES: {{^}}auto dec1() -> decltype(1 + 2) { return 1 + 2; }{{$}}
+// CHECK-FIXES: {{^}}auto dec1() -> decltype(1 + 2) { return 1 + 2; }{{$}}
 template 
 decltype(std::declval(std::declval)) dec2(F f, T t) { return f(t); }
 // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// TODO: source range of DecltypeTypeLoc not yet implemented
-// _HECK-FIXES: {{^}}auto dec2(F f, T t) -> decltype(std::declval(std::declval)) { return f(t); }{{$}}
+// CHECK-FIXES: {{^}}auto dec2(F f, T t) -> decltype(std::declval(std::declval)) { return f(t); }{{$}}
 template 
 typename decltype(std::declval())::value_type dec3();
 // CHECK-MESSAGES: :[[@LINE-1]]:50: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
@@ -531,6 +543,14 @@
 return {0};
 }
 
+//
+// bug 44206, no rewrite should happen due to collision with parameter name
+//
+
+using std::ostream;
+ostream& operator<<(ostream& ostream, int i);
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}ostream& operator<<(ostream& ostream, int i);{{$}}
 
 //
 // Samples which do not trigger the check
@@ -544,7 +564,6 @@
 template  auto f(T t) -> int;
 
 auto ff();
-decltype(auto) fff();
 
 void c();
 void c(int arg);
Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type-cxx20.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type-cxx20.cpp
@@ -0,0 +1,54 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-trailing-return-type %t
+
+namespace std {
+template 
+struct is_same { static constexpr auto value = false; };
+
+template 
+struct is_same { static constexpr auto value = true; };
+
+template 
+concept floating_point = std::is_same::value || std::is_same::value || std::is_same::value;
+}
+
+//
+// Concepts
+//
+
+std::floating_point auto con1();
+// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto con1() -> std::floating_point auto;{{$}}
+
+std::floating_point auto con1() { return 3.14f; }
+// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto con1() -> std::floating_point auto { return 3.14f; }{{$}}
+
+namespace a {

[PATCH] D80198: [clangd] locateMacroAt handles patched macros

2020-05-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

(BTW this looks miles better to me, thanks for persistence!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80198



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


[PATCH] D80514: [clang-tidy] modernize-use-trailing-return-type support for C++20 concepts and decltype

2020-05-25 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber marked 2 inline comments as done.
bernhardmgruber added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type.cpp:550
+
+#if __cplusplus > 201703L /* C++2a and later */
+

njames93 wrote:
> bernhardmgruber wrote:
> > How do you want to handle these tests which require C++20? I have seen 
> > other checks use a separate file for tests which require a different 
> > language version.
> Yes, move them into a seperate file and specify `-std=c++20` in the run line
Ok, done. Thx!


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

https://reviews.llvm.org/D80514



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


[PATCH] D79961: [PGO] Fix computation of fuction Hash

2020-05-25 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 266064.
serge-sans-paille added a comment.

  Update profile data hash entries due to hash function update, unless the 
version
  used is V1, in which case we keep the buggy behavior for backward 
compatibility.


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

https://reviews.llvm.org/D79961

Files:
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/test/Profile/Inputs/c-counter-overflows.proftext
  clang/test/Profile/Inputs/c-general.profdata.v3
  clang/test/Profile/Inputs/c-general.proftext
  clang/test/Profile/Inputs/c-unprofiled-blocks.proftext
  clang/test/Profile/Inputs/cxx-rangefor.proftext
  clang/test/Profile/Inputs/cxx-throws.proftext
  clang/test/Profile/Inputs/misexpect-switch-default.proftext
  clang/test/Profile/Inputs/misexpect-switch-nonconst.proftext
  clang/test/Profile/Inputs/misexpect-switch.proftext
  clang/test/Profile/c-collision.c

Index: clang/test/Profile/c-collision.c
===
--- /dev/null
+++ clang/test/Profile/c-collision.c
@@ -0,0 +1,22 @@
+// Test that a slight change in the code leads to a different hash.
+// RUN: %clang_cc1 -UEXTRA -triple x86_64-unknown-linux-gnu -main-file-name c-collision.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s --check-prefix=CHECK-NOEXTRA
+// RUN: %clang_cc1 -DEXTRA -triple x86_64-unknown-linux-gnu -main-file-name c-collision.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s --check-prefix=CHECK-EXTRA
+
+// CHECK-NOEXTRA: @__profd_foo = private global { {{.*}} } { i64 6699318081062747564, i64 7156072912471487002,
+// CHECK-EXTRA:   @__profd_foo = private global { {{.*}} } { i64 6699318081062747564, i64 -4383447408116050035,
+
+extern int bar;
+void foo() {
+  if (bar) {
+  }
+  if (bar) {
+  }
+  if (bar) {
+if (bar) {
+#ifdef EXTRA
+  if (bar) {
+  }
+#endif
+}
+  }
+}
Index: clang/test/Profile/Inputs/misexpect-switch.proftext
===
--- clang/test/Profile/Inputs/misexpect-switch.proftext
+++ clang/test/Profile/Inputs/misexpect-switch.proftext
@@ -1,6 +1,6 @@
 main
 # Func Hash:
-1965403898329309329
+872687477373597607
 # Num Counters:
 9
 # Counter Values:
Index: clang/test/Profile/Inputs/misexpect-switch-nonconst.proftext
===
--- clang/test/Profile/Inputs/misexpect-switch-nonconst.proftext
+++ clang/test/Profile/Inputs/misexpect-switch-nonconst.proftext
@@ -1,6 +1,6 @@
 main
 # Func Hash:
-1965403898329309329
+3721743393642630379
 # Num Counters:
 10
 # Counter Values:
Index: clang/test/Profile/Inputs/misexpect-switch-default.proftext
===
--- clang/test/Profile/Inputs/misexpect-switch-default.proftext
+++ clang/test/Profile/Inputs/misexpect-switch-default.proftext
@@ -1,6 +1,6 @@
 main
 # Func Hash:
-8712453512413296413
+8734802134600123338
 # Num Counters:
 9
 # Counter Values:
Index: clang/test/Profile/Inputs/cxx-throws.proftext
===
--- clang/test/Profile/Inputs/cxx-throws.proftext
+++ clang/test/Profile/Inputs/cxx-throws.proftext
@@ -1,5 +1,5 @@
 _Z6throwsv
-340120998528097520
+18172607911962830854
 9
 1
 100
Index: clang/test/Profile/Inputs/cxx-rangefor.proftext
===
--- clang/test/Profile/Inputs/cxx-rangefor.proftext
+++ clang/test/Profile/Inputs/cxx-rangefor.proftext
@@ -1,5 +1,5 @@
 _Z9range_forv
-6169071350249721981
+8789831523895825398
 5
 1
 4
Index: clang/test/Profile/Inputs/c-unprofiled-blocks.proftext
===
--- clang/test/Profile/Inputs/c-unprofiled-blocks.proftext
+++ clang/test/Profile/Inputs/c-unprofiled-blocks.proftext
@@ -1,5 +1,5 @@
 never_called
-5644096560937528444
+6820425066224770721
 9
 0
 0
@@ -17,7 +17,7 @@
 1
 
 dead_code
-9636018207904213947
+5254464978620792806
 10
 1
 0
Index: clang/test/Profile/Inputs/c-general.proftext
===
--- clang/test/Profile/Inputs/c-general.proftext
+++ clang/test/Profile/Inputs/c-general.proftext
@@ -7,7 +7,7 @@
 75
 
 conditionals
-4190663230902537370
+4904767535850050386
 11
 1
 100
@@ -22,7 +22,7 @@
 100
 
 early_exits
-8265526549255474475
+2880354649761471549
 9
 1
 0
@@ -35,7 +35,7 @@
 0
 
 jumps
-15872630527555456493
+15051420506203462683
 22
 1
 1
@@ -61,7 +61,7 @@
 9
 
 switches
-11892326508727782373
+43242458792028222
 19
 1
 1
@@ -84,7 +84,7 @@
 0
 
 big_switch
-16933280399284440835
+13144136522122330070
 17
 1
 32
@@ -117,7 +117,7 @@
 50
 
 boolop_loops
-11270260636676715317
+12402604614320574815
 9
 1
 50
@@ -137,7 +137,7 @@
 1
 
 do_fallthrough
-6898770640283947069
+8714614136504380050
 4
 1
 10
Index: clang/test/Profile/Inputs/c-counter-overflows.proftext

[PATCH] D79961: [PGO] Fix computation of fuction Hash

2020-05-25 Thread serge via Phabricator via cfe-commits
serge-sans-paille reopened this revision.
serge-sans-paille added a subscriber: bkramer.
serge-sans-paille added a comment.
This revision is now accepted and ready to land.

@bkramer rightfully reverted this, faster than I could patch it :-) Here is the 
patch though, with the updated test case. @hans the only meaningful change is 
that I'm keeping the buggy behavior for hash v1 for compatibility reason.


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

https://reviews.llvm.org/D79961



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


[PATCH] D79121: Add nomerge statement attribute to clang

2020-05-25 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu closed this revision.
zequanwu added a comment.

landed


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

https://reviews.llvm.org/D79121



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


[PATCH] D80532: [NFC] Fix formatting for the 'aix-ld.c' test case.

2020-05-25 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 266081.
stevewan added a comment.

Pass 'clang-format' checking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80532

Files:
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -2,177 +2,177 @@
 // sysroot to make these tests independent of the host system.
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit.
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target powerpc-ibm-aix7.1.0.0 \
-// RUN: --sysroot %S/Inputs/aix_ppc_tree \
-// RUN:   | FileCheck --check-prefix=CHECK-LD32 %s
+// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN:-target powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LD32 %s
 // CHECK-LD32-NOT: warning:
-// CHECK-LD32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
-// CHECK-LD32: "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-LD32: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD32-NOT: "-bnso"
-// CHECK-LD32: "-b32" 
-// CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000" 
-// CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32: "-L[[SYSROOT]]/usr/lib" 
-// CHECK-LD32: "-lc"
+// CHECK-LD32: "-b32"
+// CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000"
+// CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD32: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit.
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target powerpc64-ibm-aix7.1.0.0 \
-// RUN: --sysroot %S/Inputs/aix_ppc_tree \
-// RUN:   | FileCheck --check-prefix=CHECK-LD64 %s
+// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN:-target powerpc64-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LD64 %s
 // CHECK-LD64-NOT: warning:
-// CHECK-LD64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
-// CHECK-LD64: "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-LD64: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD64-NOT: "-bnso"
-// CHECK-LD64: "-b64" 
-// CHECK-LD64: "-bpT:0x1" "-bpD:0x11000" 
-// CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
-// CHECK-LD64: "-L[[SYSROOT]]/usr/lib" 
-// CHECK-LD64: "-lc"
+// CHECK-LD64: "-b64"
+// CHECK-LD64: "-bpT:0x1" "-bpD:0x11000"
+// CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
+// CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD64: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable POSIX thread support.
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -pthread \
-// RUN: -target powerpc-ibm-aix7.1.0.0 \
-// RUN: --sysroot %S/Inputs/aix_ppc_tree \
-// RUN:   | FileCheck --check-prefix=CHECK-LD32-PTHREAD %s
+// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN:-pthread \
+// RUN:-target powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LD32-PTHREAD %s
 // CHECK-LD32-PTHREAD-NOT: warning:
-// CHECK-LD32-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
-// CHECK-LD32-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-LD32-PTHREAD: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD32-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32-PTHREAD: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD32-PTHREAD-NOT: "-bnso"
-// CHECK-LD32-PTHREAD: "-b32" 
-// CHECK-LD32-PTHREAD: "-bpT:0x1000" "-bpD:0x2000" 
-// CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib"
-// CHECK-LD32-PTHREAD: "-lpthreads"
-// CHECK-LD32-PTHREAD: "-lc"
+// CHECK-LD32-PTHREAD: "-b32"
+// CHECK-LD32-PTHREAD: "-bpT:0x1000" "-bpD:0x2000"
+// CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD32-PTHREAD: "-lpthreads"
+// CHECK-LD32-PTHREAD: "-lc"
 
-// Check powerpc-ibm-aix7.1.0.0, 64-bit. POSIX thread alias.
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -pthreads \
-// RUN: -target powerpc64-ibm-aix7.1.0.0 \
-// RUN: --sysroot %S/Inputs/aix_ppc_tree \
-// RUN:   | FileCheck 

[PATCH] D79708: [clang][BFloat] add NEON emitter for bfloat

2020-05-25 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 266085.
stuij added a comment.

add bfloat header test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79708

Files:
  clang/include/clang/Basic/arm_bf16.td
  clang/include/clang/Basic/arm_neon_incl.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/test/CodeGen/arm-bf16-params-returns.c
  clang/test/Headers/arm-bf16-header.c
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Preprocessor/arm-target-features.c
  clang/utils/TableGen/NeonEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -85,6 +85,7 @@
 
 void EmitNeon(llvm::RecordKeeper , llvm::raw_ostream );
 void EmitFP16(llvm::RecordKeeper , llvm::raw_ostream );
+void EmitBF16(llvm::RecordKeeper , llvm::raw_ostream );
 void EmitNeonSema(llvm::RecordKeeper , llvm::raw_ostream );
 void EmitNeonTest(llvm::RecordKeeper , llvm::raw_ostream );
 void EmitNeon2(llvm::RecordKeeper , llvm::raw_ostream );
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -63,6 +63,7 @@
   GenClangOpenCLBuiltins,
   GenArmNeon,
   GenArmFP16,
+  GenArmBF16,
   GenArmNeonSema,
   GenArmNeonTest,
   GenArmMveHeader,
@@ -186,6 +187,7 @@
"Generate OpenCL builtin declaration handlers"),
 clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"),
 clEnumValN(GenArmFP16, "gen-arm-fp16", "Generate arm_fp16.h for clang"),
+clEnumValN(GenArmBF16, "gen-arm-bf16", "Generate arm_bf16.h for clang"),
 clEnumValN(GenArmNeonSema, "gen-arm-neon-sema",
"Generate ARM NEON sema support for clang"),
 clEnumValN(GenArmNeonTest, "gen-arm-neon-test",
@@ -360,6 +362,9 @@
   case GenArmFP16:
 EmitFP16(Records, OS);
 break;
+  case GenArmBF16:
+EmitBF16(Records, OS);
+break;
   case GenArmNeonSema:
 EmitNeonSema(Records, OS);
 break;
Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -99,7 +99,8 @@
   Poly128,
   Float16,
   Float32,
-  Float64
+  Float64,
+  BFloat16
 };
 
 } // end namespace NeonTypeFlags
@@ -147,6 +148,7 @@
 SInt,
 UInt,
 Poly,
+BFloat16,
   };
   TypeKind Kind;
   bool Immediate, Constant, Pointer;
@@ -199,6 +201,7 @@
   bool isInt() const { return isInteger() && ElementBitwidth == 32; }
   bool isLong() const { return isInteger() && ElementBitwidth == 64; }
   bool isVoid() const { return Kind == Void; }
+  bool isBFloat16() const { return Kind == BFloat16; }
   unsigned getNumElements() const { return Bitwidth / ElementBitwidth; }
   unsigned getSizeInBits() const { return Bitwidth; }
   unsigned getElementSizeInBits() const { return ElementBitwidth; }
@@ -585,8 +588,11 @@
   // runFP16 - Emit arm_fp16.h.inc
   void runFP16(raw_ostream );
 
-  // runHeader - Emit all the __builtin prototypes used in arm_neon.h
-	// and arm_fp16.h
+  // runBF16 - Emit arm_bf16.h.inc
+  void runBF16(raw_ostream );
+
+  // runHeader - Emit all the __builtin prototypes used in arm_neon.h,
+  // arm_fp16.h and arm_bf16.h
   void runHeader(raw_ostream );
 
   // runTests - Emit tests for all the Neon intrinsics.
@@ -611,6 +617,8 @@
 S += "poly";
   else if (isFloating())
 S += "float";
+  else if (isBFloat16())
+S += "bfloat";
   else
 S += "int";
 
@@ -650,7 +658,10 @@
 case 128: S += "LLLi"; break;
 default: llvm_unreachable("Unhandled case!");
 }
-  else
+  else if (isBFloat16()) {
+assert(ElementBitwidth == 16 && "BFloat16 can only be 16 bits");
+S += "y";
+  } else
 switch (ElementBitwidth) {
 case 16: S += "h"; break;
 case 32: S += "f"; break;
@@ -704,6 +715,11 @@
 Base = (unsigned)NeonTypeFlags::Float16 + (Addend - 1);
   }
 
+  if (isBFloat16()) {
+assert(Addend == 1 && "BFloat16 is only 16 bit");
+Base = (unsigned)NeonTypeFlags::BFloat16;
+  }
+
   if (Bitwidth == 128)
 Base |= (unsigned)NeonTypeFlags::QuadFlag;
   if (isInteger() && !isSigned())
@@ -727,6 +743,9 @@
   } else if (Name.startswith("poly")) {
 T.Kind = Poly;
 Name = Name.drop_front(4);
+  } else if (Name.startswith("bfloat")) {
+T.Kind = BFloat16;
+Name = Name.drop_front(6);
   } else {
 assert(Name.startswith("int"));
 Name = Name.drop_front(3);
@@ -825,6 +844,10 @@
   if (isPoly())
 NumVectors = 0;
   break;
+case 'b':
+  Kind = BFloat16;
+  ElementBitwidth = 16;
+  

[clang] 3a2df3b - [Clang][test] fix tests when using external assembler.

2020-05-25 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2020-05-25T16:47:50-07:00
New Revision: 3a2df3bad07f7e5fc22538ad782e08ee55f29e41

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

LOG: [Clang][test] fix tests when using external assembler.

Summary:
The test assume using integraed-as, so make it explicit.

Reviewered by: aganea

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

Added: 


Modified: 
clang/test/Driver/cc1-spawnprocess.c

Removed: 




diff  --git a/clang/test/Driver/cc1-spawnprocess.c 
b/clang/test/Driver/cc1-spawnprocess.c
index 8af8cc4c0555..36df7067487c 100644
--- a/clang/test/Driver/cc1-spawnprocess.c
+++ b/clang/test/Driver/cc1-spawnprocess.c
@@ -1,18 +1,23 @@
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 | FileCheck %s 
--check-prefix=YES
+// If a toolchain uses an external assembler, the test would fail because using
+// an external assember would increase job counts. Most toolchains in tree
+// use integrated assembler, but we still support external assembler.
+// So -fintegrated-as is specified explicitly when applicable.
+
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 | FileCheck %s 
--check-prefix=YES
 // RUN: %clang -fno-integrated-cc1 -c -### %s 2>&1 | FileCheck %s 
--check-prefix=NO
 
 // RUN: %clang -fintegrated-cc1 -fno-integrated-cc1 -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
-// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -fintegrated-as -c -### %s 
2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 
-// RUN: %clang_cl -fintegrated-cc1 -c -### -- %s 2>&1 \
+// RUN: %clang_cl -fintegrated-cc1 -fintegrated-as -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: %clang_cl -fno-integrated-cc1 -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
 
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fintegrated-cc1 \
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fno-integrated-cc1 \
 // RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
@@ -24,7 +29,7 @@
 // The following tests ensure that only one integrated-cc1 is executed.
 
 // Only one TU, one job, thus integrated-cc1 is enabled.
-// RUN: %clang -fintegrated-cc1 -c %s -### 2>&1 | FileCheck %s 
--check-prefix=YES
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c %s -### 2>&1 | FileCheck %s 
--check-prefix=YES
 
 // Only one TU, but we're linking, two jobs, thus integrated-cc1 is disabled.
 // RUN: %clang -fintegrated-cc1 %s -### 2>&1 | FileCheck %s --check-prefix=NO



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-05-25 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 266087.
Xiangling_L added a comment.

Adjust  `mangleDynamicDestructor`;
Add assertion and FIXME for getUniqueModuleId


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-constructor-attribute.cpp
  clang/test/CodeGen/aix-destructor-attribute.cpp
  clang/test/CodeGen/aix-init-priority-attribute.cpp
  clang/test/CodeGen/static-init.cpp

Index: clang/test/CodeGen/static-init.cpp
===
--- clang/test/CodeGen/static-init.cpp
+++ clang/test/CodeGen/static-init.cpp
@@ -1,12 +1,55 @@
-// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ < %s \
+// RUN: | FileCheck %s
 
-// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ < %s \
+// RUN: | FileCheck %s
 
 struct test {
   test();
   ~test();
 } t;
 
-// CHECK: error in backend: Static initialization has not been implemented on XL ABI yet.
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sinit8000_clang_6a64b8be19fb12e74feab8a7a858f83b, i8* null }]
+// CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sterm8000_clang_6a64b8be19fb12e74feab8a7a858f83b, i8* null }]
+// CHECK: define internal void @__cxx_global_var_init() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testC1Ev(%struct.test* @t)
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor_t)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__dtor_t() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testD1Ev(%struct.test* @t)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @atexit(void ()*)
+
+// CHECK: define internal void @__cxx_global_var_destruct_t() #0 {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor_t)
+// CHECK:   %guard.hasSrterm = icmp eq i32 %0, 0
+// CHECK:   br i1 %guard.hasSrterm, label %destruct.check, label %destruct.end
+
+// CHECK: destruct.check:
+// CHECK:   call void @__dtor_t()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @unatexit(void ()*)
+
+// CHECK: define dso_local void @__sinit8000_clang_6a64b8be19fb12e74feab8a7a858f83b() #0 {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_init()
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define dso_local void @__sterm8000_clang_6a64b8be19fb12e74feab8a7a858f83b() #0 {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_destruct_t()
+// CHECK:   ret void
+// CHECK: }
Index: clang/test/CodeGen/aix-init-priority-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-init-priority-attribute.cpp
@@ -0,0 +1,17 @@
+// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s \
+// RUN: 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm < %s \
+// RUN: 2>&1 | FileCheck %s
+
+class test {
+  int a;
+
+public:
+  test(int c) { a = c; }
+  ~test() { a = 0; }
+};
+
+__attribute__((init_priority(2000)))
+test t(1);
+
+// CHECK: fatal error: error in backend: 'init_priority' attribute unsupported on AIX yet
Index: clang/test/CodeGen/aix-destructor-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-destructor-attribute.cpp
@@ -0,0 +1,18 @@
+// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s \
+// RUN: 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm < %s \
+// RUN: 2>&1 | FileCheck %s
+
+int bar() __attribute__((destructor(180)));
+
+class test {
+  int a;
+
+public:
+  test(int c) { a = c; }
+  ~test() { a = 0; }
+};
+
+test t(1);
+
+// CHECK: fatal error: error in backend: 'destructor' attribute unsupported on AIX yet
Index: clang/test/CodeGen/aix-constructor-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-constructor-attribute.cpp
@@ -0,0 +1,18 @@
+// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s \
+// RUN: 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm < 

[PATCH] D80454: [Clang][test] fix tests when using external assembler

2020-05-25 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3a2df3bad07f: [Clang][test] fix tests when using external 
assembler. (authored by ychen).

Changed prior to commit:
  https://reviews.llvm.org/D80454?vs=265792=266088#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80454

Files:
  clang/test/Driver/cc1-spawnprocess.c


Index: clang/test/Driver/cc1-spawnprocess.c
===
--- clang/test/Driver/cc1-spawnprocess.c
+++ clang/test/Driver/cc1-spawnprocess.c
@@ -1,18 +1,23 @@
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 | FileCheck %s 
--check-prefix=YES
+// If a toolchain uses an external assembler, the test would fail because using
+// an external assember would increase job counts. Most toolchains in tree
+// use integrated assembler, but we still support external assembler.
+// So -fintegrated-as is specified explicitly when applicable.
+
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 | FileCheck %s 
--check-prefix=YES
 // RUN: %clang -fno-integrated-cc1 -c -### %s 2>&1 | FileCheck %s 
--check-prefix=NO
 
 // RUN: %clang -fintegrated-cc1 -fno-integrated-cc1 -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
-// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -fintegrated-as -c -### %s 
2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 
-// RUN: %clang_cl -fintegrated-cc1 -c -### -- %s 2>&1 \
+// RUN: %clang_cl -fintegrated-cc1 -fintegrated-as -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: %clang_cl -fno-integrated-cc1 -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
 
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fintegrated-cc1 \
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fno-integrated-cc1 \
 // RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
@@ -24,7 +29,7 @@
 // The following tests ensure that only one integrated-cc1 is executed.
 
 // Only one TU, one job, thus integrated-cc1 is enabled.
-// RUN: %clang -fintegrated-cc1 -c %s -### 2>&1 | FileCheck %s 
--check-prefix=YES
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c %s -### 2>&1 | FileCheck %s 
--check-prefix=YES
 
 // Only one TU, but we're linking, two jobs, thus integrated-cc1 is disabled.
 // RUN: %clang -fintegrated-cc1 %s -### 2>&1 | FileCheck %s --check-prefix=NO


Index: clang/test/Driver/cc1-spawnprocess.c
===
--- clang/test/Driver/cc1-spawnprocess.c
+++ clang/test/Driver/cc1-spawnprocess.c
@@ -1,18 +1,23 @@
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 | FileCheck %s --check-prefix=YES
+// If a toolchain uses an external assembler, the test would fail because using
+// an external assember would increase job counts. Most toolchains in tree
+// use integrated assembler, but we still support external assembler.
+// So -fintegrated-as is specified explicitly when applicable.
+
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 | FileCheck %s --check-prefix=YES
 // RUN: %clang -fno-integrated-cc1 -c -### %s 2>&1 | FileCheck %s --check-prefix=NO
 
 // RUN: %clang -fintegrated-cc1 -fno-integrated-cc1 -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
-// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 
-// RUN: %clang_cl -fintegrated-cc1 -c -### -- %s 2>&1 \
+// RUN: %clang_cl -fintegrated-cc1 -fintegrated-as -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: %clang_cl -fno-integrated-cc1 -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
 
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fintegrated-cc1 \
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fno-integrated-cc1 \
 // RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
@@ -24,7 +29,7 @@
 // The following tests ensure that only one integrated-cc1 is executed.
 
 // Only one TU, one job, thus integrated-cc1 is enabled.
-// RUN: %clang -fintegrated-cc1 -c %s -### 2>&1 | FileCheck %s --check-prefix=YES
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c %s -### 2>&1 | FileCheck %s --check-prefix=YES
 
 // Only one TU, but we're linking, two jobs, thus integrated-cc1 is disabled.
 // RUN: %clang -fintegrated-cc1 %s -### 2>&1 | FileCheck %s --check-prefix=NO
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

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

Rebase


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

https://reviews.llvm.org/D79773

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13537,6 +13537,7 @@
   CHECK_PARSE_BOOL(AlignConsecutiveBitFields);
   CHECK_PARSE_BOOL(AlignConsecutiveDeclarations);
   CHECK_PARSE_BOOL(AlignConsecutiveMacros);
+  CHECK_PARSE_BOOL(AlwaysBreakBeforeConceptDeclarations);
   CHECK_PARSE_BOOL(AllowAllArgumentsOnNextLine);
   CHECK_PARSE_BOOL(AllowAllConstructorInitializersOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
@@ -13557,6 +13558,7 @@
   CHECK_PARSE_BOOL(IndentCaseLabels);
   CHECK_PARSE_BOOL(IndentCaseBlocks);
   CHECK_PARSE_BOOL(IndentGotoLabels);
+  CHECK_PARSE_BOOL(IndentRequires);
   CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
   CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
   CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);
@@ -16567,6 +16569,222 @@
"}",
Style);
 }
+
+TEST_F(FormatTest, ConceptsAndRequires) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+
+  verifyFormat("template \n"
+   "concept Hashable = requires(T a) {\n"
+   "  { std::hash{}(a) } -> std::convertible_to;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "  { a != b } -> bool;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "  { a != b } -> bool;\n"
+   "};",
+   Style);
+
+  verifyFormat("template \n"
+   "requires Iterator\n"
+   "void sort(It begin, It end) {\n"
+   "  //\n"
+   "}",
+   Style);
+
+  verifyFormat("template \n"
+   "concept Large = sizeof(T) > 10;",
+   Style);
+
+  verifyFormat("template \n"
+   "concept FooableWith = requires(T t, U u) {\n"
+   "  typename T::foo_type;\n"
+   "  { t.foo(u) } -> typename T::foo_type;\n"
+   "  t++;\n"
+   "};\n"
+   "void doFoo(FooableWith auto t) {\n"
+   "  t.foo(3);\n"
+   "}",
+   Style);
+  verifyFormat("template \n"
+   "concept Context = sizeof(T) == 1;",
+   Style);
+  verifyFormat("template \n"
+   "concept Context = is_specialization_of_v;",
+   Style);
+  verifyFormat("template \n"
+   "concept Node = std::is_object_v;",
+   Style);
+  verifyFormat("template \n"
+   "concept Tree = true;",
+   Style);
+
+  verifyFormat("template  int g(T i) requires Concept1 {\n"
+   "  //...\n"
+   "}",
+   Style);
+
+  verifyFormat(
+  "template  int g(T i) requires Concept1 && Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat(
+  "template  int g(T i) requires Concept1 || Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat("template \n"
+   "veryveryvery_long_return_type g(T i) requires Concept1 || "
+   "Concept2 {\n"
+   "  //...\n"
+   "}",
+   Style);
+
+  verifyFormat("template \n"
+   "veryveryvery_long_return_type g(T i) requires Concept1 && "
+   "Concept2 {\n"
+   "  //...\n"
+   "}",
+   Style);
+
+  verifyFormat(
+  "template \n"
+  "veryveryvery_long_return_type g(T i) requires Concept1 && Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat(
+  "template \n"
+  "veryveryvery_long_return_type g(T i) requires Concept1 || Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat("template \n"
+   "requires Foo() && Bar {\n"
+   "  //\n"
+   "}",
+   Style);
+
+  verifyFormat("template \n"
+   "requires 

[PATCH] D80383: Add AST_SIGNATURE record to unhashed control block of PCM files

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

This should address the Windows test failure as well as some offline feedback

- Ensure that DeclOffset instances can only be read by providing an offset to 
the AST block
- Simplify ASTSignature test by using -fdisable-module-hash


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80383

Files:
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/include/clang/Serialization/ModuleFile.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/Modules/ASTSignature.c
  clang/test/Modules/Inputs/ASTHash/module.modulemap
  clang/test/Modules/Inputs/ASTHash/my_header_1.h
  clang/test/Modules/Inputs/ASTHash/my_header_2.h

Index: clang/test/Modules/Inputs/ASTHash/my_header_2.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/ASTHash/my_header_2.h
@@ -0,0 +1,3 @@
+#include "my_header_1.h"
+
+extern my_int var;
Index: clang/test/Modules/Inputs/ASTHash/my_header_1.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/ASTHash/my_header_1.h
@@ -0,0 +1 @@
+typedef int my_int;
Index: clang/test/Modules/Inputs/ASTHash/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/ASTHash/module.modulemap
@@ -0,0 +1,8 @@
+module MyHeader1 {
+  header "my_header_1.h"
+}
+
+module MyHeader2 {
+  header "my_header_2.h"
+  export *
+}
Index: clang/test/Modules/ASTSignature.c
===
--- /dev/null
+++ clang/test/Modules/ASTSignature.c
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -iquote %S/Inputs/ASTHash/ -fsyntax-only -fmodules \
+// RUN:   -fimplicit-module-maps -fmodules-strict-context-hash \
+// RUN:   -fmodules-cache-path=%t -fdisable-module-hash %s
+// RUN: cp %t/MyHeader2.pcm %t1.pcm
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -iquote "/dev/null" -iquote %S/Inputs/ASTHash/ -fsyntax-only \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-strict-context-hash \
+// RUN:   -fmodules-cache-path=%t -fdisable-module-hash %s
+// RUN: cp %t/MyHeader2.pcm %t2.pcm
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t1.pcm > %t1.dump
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t2.pcm > %t2.dump
+// RUN: cat %t1.dump %t2.dump | FileCheck %s
+
+#include "my_header_2.h"
+
+my_int var = 42;
+
+// CHECK: [[AST_SIGNATURE:]]
+// CHECK: [[SIGNATURE:]]
+// CHECK: [[AST_SIGNATURE]]
+// CHECK-NOT: [[SIGNATURE]]
+// The modules built by this test are designed to yield the same AST. If this
+// test fails, it means that the AST block is has become non-relocatable.
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2434,12 +2434,12 @@
   SourceLocation Loc = D->getLocation();
   unsigned Index = ID - FirstDeclID;
   if (DeclOffsets.size() == Index)
-DeclOffsets.emplace_back(Loc, Offset);
+DeclOffsets.emplace_back(Loc, Offset, ASTBlockRange.first);
   else if (DeclOffsets.size() < Index) {
 // FIXME: Can/should this happen?
 DeclOffsets.resize(Index+1);
 DeclOffsets[Index].setLocation(Loc);
-DeclOffsets[Index].setBitOffset(Offset);
+DeclOffsets[Index].setBitOffset(Offset, ASTBlockRange.first);
   } else {
 llvm_unreachable("declarations should be emitted in ID order");
   }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -10,14 +10,12 @@
 //
 //===--===//
 
-#include "clang/AST/OpenMPClause.h"
-#include "clang/Serialization/ASTRecordWriter.h"
 #include "ASTCommon.h"
 #include "ASTReaderInternals.h"
 #include "MultiOnDiskHashTable.h"
-#include "clang/AST/AbstractTypeWriter.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTUnresolvedSet.h"
+#include "clang/AST/AbstractTypeWriter.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
@@ -31,6 +29,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/LambdaCapture.h"
 #include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/OpenMPClause.h"
 #include "clang/AST/RawCommentList.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
@@ -65,7 +64,9 @@
 #include "clang/Sema/ObjCMethodList.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/Weak.h"
+#include 

[PATCH] D79800: [Sema] Implement DR2233

2020-05-25 Thread Raul Tambre via Phabricator via cfe-commits
tambre updated this revision to Diff 265855.
tambre marked an inline comment as done.
tambre added a comment.

Improve comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79800

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CXX/drs/dr22xx.cpp
  clang/test/CXX/drs/dr7xx.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -4681,7 +4681,7 @@
 https://wg21.link/cwg777;>777
 CD2
 Default arguments and parameter packs
-Clang 3.7
+Superseded by 2233
   
   
 https://wg21.link/cwg778;>778
@@ -13213,7 +13213,7 @@
 https://wg21.link/cwg2233;>2233
 DRWP
 Function parameter packs following default arguments
-Unknown
+Clang 11
   
   
 https://wg21.link/cwg2234;>2234
Index: clang/test/CXX/drs/dr7xx.cpp
===
--- clang/test/CXX/drs/dr7xx.cpp
+++ clang/test/CXX/drs/dr7xx.cpp
@@ -219,16 +219,4 @@
   Collision c; // expected-note {{in instantiation of}}
 }
 
-namespace dr777 { // dr777: 3.7
-#if __cplusplus >= 201103L
-template 
-void f(int i = 0, T ...args) {}
-void ff() { f(); }
-
-template 
-void g(int i = 0, T ...args, T ...args2) {}
-
-template 
-void h(int i = 0, T ...args, int j = 1) {}
-#endif
-}
+// dr777 superseded by dr2233
Index: clang/test/CXX/drs/dr22xx.cpp
===
--- clang/test/CXX/drs/dr22xx.cpp
+++ clang/test/CXX/drs/dr22xx.cpp
@@ -35,3 +35,44 @@
   }
 #endif
 }
+
+namespace dr2233 { // dr2233: 11
+#if __cplusplus >= 201103L
+template 
+void f(int i = 0, T... args) {}
+
+template 
+void g(int i = 0, T... args, T... args2) {}
+
+template 
+void h(int i = 0, T... args, int j = 1) {}
+
+template 
+void i(int i = 0, T... args, int j = 1, U... args2) {}
+
+template 
+void j(int i = 0, Ts... ts) {}
+
+template <>
+void j(int i, int j) {}
+
+// PR23029
+// Ensure instantiating the templates works.
+void use() {
+  f();
+  f(0, 1);
+  f(1, 2);
+  g(1, 2, 3);
+  h(0, 1);
+  i();
+  i(3);
+  i(3, 2);
+  i(3, 2, 1);
+  i(1, 2, 3, 4, 5);
+  j();
+  j(1);
+  j(1, 2);
+  j(1, 2);
+}
+#endif
+} // namespace dr2233
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1974,6 +1974,48 @@
 TemplateArgumentList::CreateCopy(SemaRef.Context,
  Innermost),
 /*InsertPos=*/nullptr);
+
+// DR777, DR2233.
+// Parameter packs are allowed after and inbetween parameters with default
+// values. We need to remove default arguments for parameters before the
+// first expanded parameter pack to prevent the declaration being diagnosed
+// as invalid due to the expanded parameters after parameters with default
+// values lacking default values. This is safe to do because if a parameter
+// pack is expanded the user must've provided arguments for all parameters
+// before it.
+FunctionDecl *TemplatedDecl = FunctionTemplate->getTemplatedDecl();
+unsigned FirstPack = Function->getNumParams();
+bool RemoveDefaults = false;
+
+// Go backwards through the template declaration parameters and find the
+// first parameter pack, which has non-zero number of arguments.
+for (unsigned p = TemplatedDecl->getNumParams(); p-- > 0;) {
+  ParmVarDecl *Param = TemplatedDecl->getParamDecl(p);
+
+  if (Param->isParameterPack()) {
+llvm::Optional Args =
+SemaRef.getNumArgumentsInExpansion(Param->getType(), TemplateArgs);
+assert(Args != None && "Unknown number of pack expansion arguments.");
+
+if (Args.getValue() == 0)
+  continue;
+
+FirstPack -= Args.getValue();
+RemoveDefaults = true;
+break;
+  } else {
+FirstPack--;
+  }
+}
+
+// If we found such a parameter pack, then remove default arguments for all
+// parameters before it.
+if (RemoveDefaults) {
+  for (unsigned p = 0; p < FirstPack; p++) {
+ParmVarDecl *Param = Function->getParamDecl(p);
+Param->setDefaultArg(nullptr);
+  }
+}
   } else if (isFriend && D->isThisDeclarationADefinition()) {
 // Do not connect the friend to the template unless it's actually a
 // definition. We don't want non-template functions to be marked as being
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79800: [Sema] Implement DR2233

2020-05-25 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

Thanks for the reviews!
I believe this now handles all cases and with this we're standards-conforming 
in regard to DR777 and DR2233.




Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:1987
+
+if (Function->getNumParams() >= NumTemplatedParams) {
+  unsigned FirstDefault = 0;

rjmccall wrote:
> I don't think this simple comparison works; the relationship can be 
> complicated because there might be multiple packs in play.  By the same 
> token, I think it's possible that there can be multiple interleavings of 
> defaultable parameters with packs.  I think you need to scan backwards 
> looking for a parameter without a default argument that was instantiated from 
> a pack expansion and then remove any earlier parameters with defaults.
> 
> That is, assuming this is a reasonable implementation approach at all 
> compared to just teaching other parts of the compiler about this case, which 
> I think Richard needs to weigh in on.
Good point, my current change doesn't work in the following case:


```
template
void g(int i = 1, Ts... ts, int j = 3, As... as)
{
}

void testg()
{
g(2, 3, 4, 5);
}
```

Fixed and added that as a test case.

I think this approach is fine, as keeping info for each parameter for how they 
were expanded doesn't seem reasonable. Cases such as this ought to be checked 
and handled early during the actual template instantiation not during later 
checking of the instantiated function declaration.



Comment at: clang/test/CXX/drs/dr7xx.cpp:225
 template 
 void f(int i = 0, T ...args) {}
 void ff() { f(); }

Quuxplusone wrote:
> rjmccall wrote:
> > Quuxplusone wrote:
> > > Is this even supposed to compile? The only valid specializations of `f` 
> > > require `T...` to be an empty pack, which violates 
> > > [temp.res/8.3](https://timsong-cpp.github.io/cppwp/temp.res#8.3).
> > > 
> > > The comment mentions 
> > > [DR777](http://cwg-issue-browser.herokuapp.com/cwg777), but DR777 doesn't 
> > > explain the circumstances under which its wording change matters. It 
> > > //seems// only to apply to templates that are already ill-formed by 
> > > temp.res/8.3.
> > Yeah, Richard made this point in 
> > [[http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2233|DR2233]],
> >  and the wording was weakened to allow it, in a way that essentially makes 
> > the earlier default arguments dead.
> Huh. Ick. Indeed the other vendors seem to be implementing DR777/DR2233, so I 
> guess Clang ought to catch up even if it's a silly direction to go in. :( I 
> do see a small bit of implementation divergence in 
> https://godbolt.org/z/ZMCvAX —
> ```
> template
> int f(int i=1, Ts... ts) { return (i + ... + ts); }
> 
> template<>
> int f(int i, int j) { return 42; }
> ```
> GCC rejects as ill-formed. MSVC makes the specialization callable with 2 
> arguments only. EDG (ICC) makes the specialization callable with 0 or 2 
> arguments (and does [crazy things](https://godbolt.org/z/QTrVeh) when you 
> call it with 0 arguments).
MSVC [[ https://godbolt.org/z/FCtrcs | seems to be the most standard-conforming 
]] in this regard. And now with the revised patch Clang is on par. :)

[[ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95287 | GCC bug ]]
[[ 
https://developercommunity.visualstudio.com/content/problem/1046639/incorrect-intellisense-for-functions-with-a-defaul.html
 | IntelliSense bug ]]

I also submitted bug reports to ICC, but those seem to need moderator approval 
before they're public.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79800



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


[PATCH] D69764: [clang-format] Add Left/Right Const fixer capability

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

In D69764#2050226 , @steveire wrote:

> I like the approach of using clang-format to implement this. It's much faster 
> than a `clang-tidy` approach.
>
> The broader C++ community has already chosen `East`/`West` and it has 
> momentum. If you choose `Left`/`Right` now, you will get pressure to add 
> `East`/`West` in the future, which means we'll have the synonyms we want to 
> avoid.
>
> The broader C++ community already has understanding of `East`/`West`. Trying 
> to change that now should be out of scope for this patch. This patch should 
> use `East`/`West`.


As a member of the C++ committee, I'm aware that any statements about what the 
broader C++ community understands are not to be taken too seriously; none of us 
know what ~5M people understand or don't.

I would like to reiterate my discomfort with using East/West as the identifiers 
here. The purpose to this functionality is to decide whether to put qualifiers 
before or after the base type -- use of east/west to describe relative 
locations like these is not idiomatic in the same way as left/right or 
before/after (e.g., I'm not east-handed and you don't put the cart to the west 
of the horse). Qualifiers have been in C++ for ~40 years and the notion of 
east/west terminology is a very recent evolution by comparison. Also, 
clang-format is not a formatter for C++ alone and the east/west terminology is 
likely even less-known to users of the other languages despite also having 
qualifiers that need formatting (e.g., C and Obj). I think these are valid 
technical concerns with the patch that we should not hand-wave away as matters 
of preference.




Comment at: clang/lib/Format/Format.cpp:2547
 
+  if (Style.isCpp() || Style.Language == FormatStyle::LK_ObjC) {
+if (Style.ConstStyle != FormatStyle::CS_Leave)

This prevents us from using this in C code despite C having qualifiers that can 
go to the left or right of the base type but still allows you to use if from 
Objective-C. That seems incorrect.


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

https://reviews.llvm.org/D69764



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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

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

In D80344#2051804 , @tentzen wrote:

> > It may be helpful (even for the reviewers) to first specify their behavior,
> >  instead of writing that after-the-fact "backwardly" based on the 
> > implementation.
>
> For reviewers, the purpose of those intrinsic are described in Summary 
> section:


Like the disscussion we just had in HWLoops patch, unless the behavior of new 
intrinsics/etc is stated in langref, they are unspecified.

> - Two intrinsic are created to track CPP object scopes; eha_scope_begin() and 
> eha_scope_end(). _scope_begin() is immediately added after ctor() is called 
> and EHStack is pushed. So it must be an invoke, not a call. With that it's 
> also guaranteed an EH-cleanup-pad is created regardless whether there exists 
> a call in this scope. _scope_end is added before dtor(). These two intrinsics 
> make the computation of Block-State possible in downstream code gen pass, 
> even in the presence of ctor/dtor inlining.
> - Two intrinsic, seh_try_begin() and seh_try_end(), are added for C-code to 
> mark _try boundary and to prevent from exceptions being moved across _try 
> boundary.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344



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


[PATCH] D80239: [libTooling] In Transformer, allow atomic changes to span multiple files.

2020-05-25 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/Transformer/Transformer.cpp:65
 
-  for (const auto  : Case.AddedIncludes) {
-auto  = I.first;
-switch (I.second) {
-case transformer::IncludeFormat::Quoted:
-  AC.addHeader(Header);
-  break;
-case transformer::IncludeFormat::Angled:
-  AC.addHeader((llvm::Twine("<") + Header + ">").str());
-  break;
+  for (auto  : ChangesByFileID) {
+auto  = IDChangePair.second;

The test shows an example transformer that removes code, so the header 
insertion logic is not triggered there. However, for a change that would be 
adding code, is it correct to insert the header into every file being edited? I 
think not necessarily. Or do you prefer to deal with this issue when we have a 
sample use case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80239



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


[clang] 2e43bab - [docs] Fix warnings in ConstantInterpreter

2020-05-25 Thread Jinsong Ji via cfe-commits

Author: Jinsong Ji
Date: 2020-05-23T19:36:05Z
New Revision: 2e43bab1c161a97df4883def3c4c4a8b92883377

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

LOG: [docs] Fix warnings in ConstantInterpreter

Fixed following trivial issues that caught by warnings by adding
indents.

clang/docs/ConstantInterpreter.rst:133: WARNING: Bullet list ends
without a blank line; unexpected unindent.
clang/docs/ConstantInterpreter.rst:136: WARNING: Bullet list ends
without a blank line; unexpected unindent.
clang/docs/ConstantInterpreter.rst:153: WARNING: Bullet list ends
without a blank line; unexpected unindent.
clang/docs/ConstantInterpreter.rst:195: WARNING: Bullet list ends
without a blank line; unexpected unindent.
clang/docs/ConstantInterpreter.rst:225: WARNING: Bullet list ends
without a blank line; unexpected unindent.
clang/docs/ConstantInterpreter.rst:370: WARNING: Bullet list ends
without a blank line; unexpected unindent.
clang/docs/ConstantInterpreter.rst:383: WARNING: Bullet list ends
without a blank line; unexpected unindent.

Added: 


Modified: 
clang/docs/ConstantInterpreter.rst

Removed: 




diff  --git a/clang/docs/ConstantInterpreter.rst 
b/clang/docs/ConstantInterpreter.rst
index c976f35a67c5..eba637585b8f 100644
--- a/clang/docs/ConstantInterpreter.rst
+++ b/clang/docs/ConstantInterpreter.rst
@@ -13,7 +13,7 @@ clang, improving performance on constructs which are executed 
inefficiently
 by the evaluator. The interpreter is activated using the following flags:
 
 * ``-fexperimental-new-constant-interpreter`` enables the interpreter,
-emitting an error if an unsupported feature is encountered
+  emitting an error if an unsupported feature is encountered
 
 Bytecode Compilation
 
@@ -130,11 +130,11 @@ descriptor that characterises the entire allocation, 
along with a few
 additional attributes:
 
 * ``IsStatic`` indicates whether the block has static duration in the
-interpreter, i.e. it is not a local in a frame.
+  interpreter, i.e. it is not a local in a frame.
 
 * ``DeclID`` identifies each global declaration (it is set to an invalid
-and irrelevant value for locals) in order to prevent illegal writes and
-reads involving globals and temporaries with static storage duration.
+  and irrelevant value for locals) in order to prevent illegal writes and
+  reads involving globals and temporaries with static storage duration.
 
 Static blocks are never deallocated, but local ones might be deallocated
 even when there are live pointers to them. Pointers are only valid as
@@ -150,8 +150,8 @@ The lifetime of blocks is managed through 3 methods stored 
in the
 descriptor of the block:
 
 * **CtorFn**: initializes the metadata which is store in the block,
-alongside actual data. Invokes the default constructors of objects
-which are not trivial (``Pointer``, ``RealFP``, etc.)
+  alongside actual data. Invokes the default constructors of objects
+  which are not trivial (``Pointer``, ``RealFP``, etc.)
 
 * **DtorFn**: invokes the destructors of non-trivial objects.
 
@@ -192,13 +192,13 @@ The interpreter distinguishes 3 
diff erent kinds of blocks:
   has the following fields:
 
* **Offset**: byte offset into the array or record, used to step back to the
-   parent array or record.
+ parent array or record.
* **IsConst**: flag indicating if the field is const-qualified.
* **IsInitialized**: flag indicating whether the field or element was
-   initialized. For non-primitive fields, this is only relevant to determine
-   the dynamic type of objects during construction.
+ initialized. For non-primitive fields, this is only relevant to determine
+ the dynamic type of objects during construction.
* **IsBase**: flag indicating whether the record is a base class. In that
-   case, the offset can be used to identify the derived class.
+ case, the offset can be used to identify the derived class.
* **IsActive**: indicates if the field is the active field of a union.
* **IsMutable**: indicates if the field is marked as mutable.
 
@@ -222,19 +222,19 @@ Pointers, implemented in ``Pointer.h`` are represented as 
a tagged union.
 Some of these may not yet be available in upstream ``clang``.
 
  * **BlockPointer**: used to reference memory allocated and managed by the
- interpreter, being the only pointer kind which allows dereferencing in the
- interpreter
+   interpreter, being the only pointer kind which allows dereferencing in the
+   interpreter
  * **ExternPointer**: points to memory which can be addressed, but not read by
- the interpreter. It is equivalent to APValue, tracking a declaration and a 
path
- of fields and indices into that allocation.
+   the interpreter. It is equivalent to APValue, tracking a declaration and a 

[PATCH] D76801: [AST] Print a> without extra spaces in C++11 or later.

2020-05-25 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

Hi, we noticed an issue with the GDB test suite that was bisected back to this 
change and I have put the details in PR46052. Can you take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76801



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


[PATCH] D69764: [clang-format] Add East/West Const fixer capability

2020-05-25 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 265949.
MyDeveloperDay retitled this revision from "[clang-format] Add Left/Right Const 
fixer capability" to "[clang-format] Add East/West Const fixer capability".
MyDeveloperDay added a comment.

Add more test cases
Cover more template and namespace cases


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

https://reviews.llvm.org/D69764

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/CMakeLists.txt
  clang/lib/Format/EastWestConstFixer.cpp
  clang/lib/Format/EastWestConstFixer.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13628,6 +13628,11 @@
   CHECK_PARSE("ContinuationIndentWidth: 11", ContinuationIndentWidth, 11u);
   CHECK_PARSE("CommentPragmas: '// abc$'", CommentPragmas, "// abc$");
 
+  Style.ConstStyle = FormatStyle::CS_West;
+  CHECK_PARSE("ConstStyle: Leave", ConstStyle, FormatStyle::CS_Leave);
+  CHECK_PARSE("ConstStyle: East", ConstStyle, FormatStyle::CS_East);
+  CHECK_PARSE("ConstStyle: West", ConstStyle, FormatStyle::CS_West);
+
   Style.PointerAlignment = FormatStyle::PAS_Middle;
   CHECK_PARSE("PointerAlignment: Left", PointerAlignment,
   FormatStyle::PAS_Left);
@@ -16567,6 +16572,245 @@
"}",
Style);
 }
+
+TEST_F(FormatTest, EastWestConst) {
+  FormatStyle Style = getLLVMStyle();
+
+  // keep the const style unaltered
+  verifyFormat("const int a;", Style);
+  verifyFormat("const int *a;", Style);
+  verifyFormat("const int ", Style);
+  verifyFormat("const int &", Style);
+  verifyFormat("int const b;", Style);
+  verifyFormat("int const *b;", Style);
+  verifyFormat("int const ", Style);
+  verifyFormat("int const &", Style);
+  verifyFormat("int const *b const;", Style);
+  verifyFormat("int *const c;", Style);
+
+  verifyFormat("const Foo a;", Style);
+  verifyFormat("const Foo *a;", Style);
+  verifyFormat("const Foo ", Style);
+  verifyFormat("const Foo &", Style);
+  verifyFormat("Foo const b;", Style);
+  verifyFormat("Foo const *b;", Style);
+  verifyFormat("Foo const ", Style);
+  verifyFormat("Foo const &", Style);
+  verifyFormat("Foo const *b const;", Style);
+
+  verifyFormat("LLVM_NODISCARD const int ();", Style);
+  verifyFormat("LLVM_NODISCARD int const ();", Style);
+
+  verifyFormat("volatile const int *restrict;", Style);
+  verifyFormat("const volatile int *restrict;", Style);
+  verifyFormat("const int volatile *restrict;", Style);
+}
+
+TEST_F(FormatTest, EastConst) {
+  FormatStyle Style = getLLVMStyle();
+  Style.ConstStyle = FormatStyle::CS_East;
+
+  verifyFormat("int const a;", Style);
+  verifyFormat("int const *a;", Style);
+  verifyFormat("int const ", Style);
+  verifyFormat("int const &", Style);
+  verifyFormat("int const b;", Style);
+  verifyFormat("int const *b;", Style);
+  verifyFormat("int const ", Style);
+  verifyFormat("int const &", Style);
+  verifyFormat("int const *b const;", Style);
+  verifyFormat("int *const c;", Style);
+
+  verifyFormat("Foo const a;", Style);
+  verifyFormat("Foo const *a;", Style);
+  verifyFormat("Foo const ", Style);
+  verifyFormat("Foo const &", Style);
+  verifyFormat("Foo const b;", Style);
+  verifyFormat("Foo const *b;", Style);
+  verifyFormat("Foo const ", Style);
+  verifyFormat("Foo const &", Style);
+  verifyFormat("Foo const *b const;", Style);
+  verifyFormat("Foo *const b;", Style);
+  verifyFormat("Foo const *const b;", Style);
+  verifyFormat("auto const v = get_value();", Style);
+  verifyFormat("long long const ", Style);
+  verifyFormat("unsigned char const *a;", Style);
+  verifyFormat("int main(int const argc, char const *const *const argv)",
+   Style);
+
+  verifyFormat("LLVM_NODISCARD int const ();", Style);
+  verifyFormat("SourceRange getSourceRange() const override LLVM_READONLY",
+   Style);
+  verifyFormat("void foo() const override;", Style);
+  verifyFormat("void foo() const override LLVM_READONLY;", Style);
+  verifyFormat("void foo() const final;", Style);
+  verifyFormat("void foo() const final LLVM_READONLY;", Style);
+  verifyFormat("void foo() const LLVM_READONLY;", Style);
+
+  verifyFormat(
+  "template  explicit Action(Action const );",
+  Style);
+  verifyFormat(
+  "template  explicit Action(Action const );",
+  "template  explicit Action(const Action& action);",
+  Style);
+  verifyFormat(
+  "template  explicit Action(Action const );",
+  "template \nexplicit Action(const Action& action);",
+  Style);
+
+  verifyFormat("int const a;", "const int a;", Style);
+  verifyFormat("int const *a;", "const int *a;", Style);
+  verifyFormat("int const ", "const int ", 

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

2020-05-25 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 265946.
steveire added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72534

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ParentMapContext.h


Index: clang/include/clang/AST/ParentMapContext.h
===
--- clang/include/clang/AST/ParentMapContext.h
+++ clang/include/clang/AST/ParentMapContext.h
@@ -67,7 +67,7 @@
 private:
   ASTContext 
   class ParentMap;
-  TraversalKind Traversal = TK_AsIs;
+  TraversalKind Traversal = TK_IgnoreUnlessSpelledInSource;
   std::unique_ptr Parents;
 };
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -246,7 +246,14 @@
 AST Matchers
 
 
-- ...
+- Traversal in AST Matchers was simplified to use the
+  ``TK_IgnoreUnlessSpelledInSource`` mode by default, instead of ``TK_AsIs``.
+  This means that many uses of the ``ignoringImplicit()`` and similar matchers
+  is no longer necessary.  Clients of AST Matchers which wish to match on
+  implicit AST nodes can wrap their matcher in ``traverse(TK_AsIs, ...)`` or
+  use ``TraversalKindScope`` if appropriate.  The ``clang-query`` tool also
+  uses ``IgnoreUnlessSpelledInSource`` by default.  The mode can be changed
+  using ``set traversal AsIs`` in the ``clang-query`` environment.
 
 clang-format
 


Index: clang/include/clang/AST/ParentMapContext.h
===
--- clang/include/clang/AST/ParentMapContext.h
+++ clang/include/clang/AST/ParentMapContext.h
@@ -67,7 +67,7 @@
 private:
   ASTContext 
   class ParentMap;
-  TraversalKind Traversal = TK_AsIs;
+  TraversalKind Traversal = TK_IgnoreUnlessSpelledInSource;
   std::unique_ptr Parents;
 };
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -246,7 +246,14 @@
 AST Matchers
 
 
-- ...
+- Traversal in AST Matchers was simplified to use the
+  ``TK_IgnoreUnlessSpelledInSource`` mode by default, instead of ``TK_AsIs``.
+  This means that many uses of the ``ignoringImplicit()`` and similar matchers
+  is no longer necessary.  Clients of AST Matchers which wish to match on
+  implicit AST nodes can wrap their matcher in ``traverse(TK_AsIs, ...)`` or
+  use ``TraversalKindScope`` if appropriate.  The ``clang-query`` tool also
+  uses ``IgnoreUnlessSpelledInSource`` by default.  The mode can be changed
+  using ``set traversal AsIs`` in the ``clang-query`` environment.
 
 clang-format
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78938: Fixing all comparisons for C++20 compilation.

2020-05-25 Thread David Stone via Phabricator via cfe-commits
davidstone added a comment.

I noticed the missing return because there is a warning (not as error) that 
caught it, I think the warning about falling off the end of a 
non-void-returning function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938



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


[PATCH] D78938: Fixing all comparisons for C++20 compilation.

2020-05-25 Thread JF Bastien via Phabricator via cfe-commits
jfb accepted this revision.
jfb added a comment.

One suggestions, otherwise looks good. Thanks for doing this :)




Comment at: llvm/include/llvm/ADT/DirectedGraph.h:97
+  }
+  friend bool operator!=(const NodeType , const NodeType ) { !(M == N); }
 

davidstone wrote:
> Missing `return`


Did this not trigger a diagnostic when building? I wonder if it's just not on?



Comment at: llvm/include/llvm/ADT/DirectedGraph.h:40
   /// Static polymorphism: delegate implementation (via isEqualTo) to the
   /// derived class.
+  bool operator==(const DGEdge ) const {

That comment, so informative! 



Comment at: llvm/unittests/ADT/STLExtrasTest.cpp:466
   std::unique_ptr V2 = std::make_unique(0);
-  EXPECT_EQ(V2.get(), to_address(V2));
+  EXPECT_EQ(V2.get(), (to_address)(V2));
 

Can you add a comment above (with "fancy pointer") so mere mortals understand 
the parens?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938



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


[PATCH] D80472: [clangd] Add access specifier information to hover contents

2020-05-25 Thread Daniel Martín via Phabricator via cfe-commits
danielmartin marked 6 inline comments as done.
danielmartin added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:680
 
+StringRef getAccessString(AccessSpecifier AS) {
+  switch (AS) {

kadircet wrote:
> it is annoying to have this function duplicated in each component (there are 
> duplicates at least in text and json node dumpers too) :/
> 
> Feel free to provide a common implementation in 
> `clang/include/clang/Basic/Specifiers.h` and migrate all other usages to it, 
> or just put a FIXME in here saying we should converge those.
> 
> nit: prefer `llvm::StringRef` as return type
I've only found usages in clang-doc, I don't know if there's more. 

I've changed them to use the new common logic in `Specifiers.h`.



Comment at: clang-tools-extra/clangd/Hover.cpp:793
+  if (AccessSpecifier != AccessSpecifier::AS_none)
+Header.appendText(getAccessString(AccessSpecifier)).appendSpace();
   if (Kind != index::SymbolKind::Unknown)

kadircet wrote:
> I wonder if it would be more natural to put this at bottom, where we list the 
> containing class/struct/union. e.g.
> 
> ```
> struct X { int fo^o; }
> ```
> 
> would result in
> 
> ```
> field foo
> ---
> 
> // In X
> public: int foo
> ```
> 
> I find current one useful too, just listing options to see what you (and 
> possibly others interested in) think.
I think it's a bit less visible, but one good thing your suggestion has is that 
in the Emacs client we use that part of the hover content to show a one liner 
with type information. So I followed your suggestion to also have access 
specifier information in our one-liner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80472



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


[clang] d0da5d2 - Change default traversal in AST Matchers to ignore invisible nodes

2020-05-25 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2020-05-25T00:18:54+01:00
New Revision: d0da5d2bbe8305d06dc01a98706fd73e11e24a9f

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

LOG: Change default traversal in AST Matchers to ignore invisible nodes

This makes many scenarios simpler by not requiring the user to write
ignoringImplicit() all the time, nor to account for non-visible
cxxConstructExpr() and cxxMemberCalExpr() nodes. This is also, in part,
inclusive of the equivalent of adding a use of ignoringParenImpCasts()
between all expr()-related matchers in an expression.

The pre-existing traverse(TK_AsIs, ...) matcher can be used to explcitly
match on implicit/invisible nodes. See

  http://lists.llvm.org/pipermail/cfe-dev/2019-December/064143.html

for more

Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/ParentMapContext.h

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 16f5915856fd..c38ff0e36790 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -246,7 +246,14 @@ release of Clang. Users of the build system should adjust 
accordingly.
 AST Matchers
 
 
-- ...
+- Traversal in AST Matchers was simplified to use the
+  ``TK_IgnoreUnlessSpelledInSource`` mode by default, instead of ``TK_AsIs``.
+  This means that many uses of the ``ignoringImplicit()`` and similar matchers
+  is no longer necessary.  Clients of AST Matchers which wish to match on
+  implicit AST nodes can wrap their matcher in ``traverse(TK_AsIs, ...)`` or
+  use ``TraversalKindScope`` if appropriate.  The ``clang-query`` tool also
+  uses ``IgnoreUnlessSpelledInSource`` by default.  The mode can be changed
+  using ``set traversal AsIs`` in the ``clang-query`` environment.
 
 clang-format
 

diff  --git a/clang/include/clang/AST/ParentMapContext.h 
b/clang/include/clang/AST/ParentMapContext.h
index be4d75df7b99..5f9936b28e8f 100644
--- a/clang/include/clang/AST/ParentMapContext.h
+++ b/clang/include/clang/AST/ParentMapContext.h
@@ -67,7 +67,7 @@ class ParentMapContext {
 private:
   ASTContext 
   class ParentMap;
-  TraversalKind Traversal = TK_AsIs;
+  TraversalKind Traversal = TK_IgnoreUnlessSpelledInSource;
   std::unique_ptr Parents;
 };
 



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


[PATCH] D69764: [clang-format] Add East/West Const fixer capability

2020-05-25 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added a comment.

> I would like to reiterate my discomfort with using East/West as the 
> identifiers here

I'd like to think that I can see it from both angles, @steveire is correct, if 
I just supply Left/Right then we'll have a request almost immediately for for 
East/West, Ultimately we'll likely not know what people prefer until its been 
used. (I'll be interested to do a search in github.com if I ever get this 
landed)




Comment at: clang/lib/Format/Format.cpp:2547
 
+  if (Style.isCpp() || Style.Language == FormatStyle::LK_ObjC) {
+if (Style.ConstStyle != FormatStyle::CS_Leave)

aaron.ballman wrote:
> This prevents us from using this in C code despite C having qualifiers that 
> can go to the left or right of the base type but still allows you to use if 
> from Objective-C. That seems incorrect.
clang-format's isCpp() covers C and C++ (and ObjectiveC and ObjectiveC++)

but you did highlight that I don't need the extra LK_ObjC check


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

https://reviews.llvm.org/D69764



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


[PATCH] D69764: [clang-format] Add East/West Const fixer capability

2020-05-25 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay planned changes to this revision.
MyDeveloperDay added a comment.

@steveire  I'm still working on this I have just one issue from your lit that 
is failing (see below), but I wanted to capture the other changes in the review.

  const Foo>* p = const_cast>*>();


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

https://reviews.llvm.org/D69764



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


[PATCH] D80517: [analyzer] CmpRuns.py: Refactor and add type annotations

2020-05-25 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80517

Files:
  clang/utils/analyzer/CmpRuns.py

Index: clang/utils/analyzer/CmpRuns.py
===
--- clang/utils/analyzer/CmpRuns.py
+++ clang/utils/analyzer/CmpRuns.py
@@ -17,26 +17,35 @@
 # Load the results of both runs, to obtain lists of the corresponding
 # AnalysisDiagnostic objects.
 #
-resultsA = loadResultsFromSingleRun(singleRunInfoA, deleteEmpty)
-resultsB = loadResultsFromSingleRun(singleRunInfoB, deleteEmpty)
+resultsA = load_results_from_single_run(singleRunInfoA, delete_empty)
+resultsB = load_results_from_single_run(singleRunInfoB, delete_empty)
 
 # Generate a relation from diagnostics in run A to diagnostics in run B
 # to obtain a list of triples (a, b, confidence).
-diff = compareResults(resultsA, resultsB)
+diff = compare_results(resultsA, resultsB)
 
 """
-from __future__ import division, print_function
-
-from collections import defaultdict
-
-from math import log
-from optparse import OptionParser
+import argparse
 import json
 import os
 import plistlib
 import re
 import sys
 
+from math import log
+from collections import defaultdict
+from copy import copy
+from typing import (Any, cast, Dict, List, Optional, Sequence, TextIO, TypeVar,
+Tuple, Union)
+
+
+Number = Union[int, float]
+Stats = Dict[str, Dict[str, Number]]
+Plist = Dict[str, Any]
+JSON = Dict[str, Any]
+# Type for generics
+T = TypeVar('T')
+
 STATS_REGEXP = re.compile(r"Statistics: (\{.+\})", re.MULTILINE | re.DOTALL)
 
 
@@ -56,118 +65,126 @@
 root - the name of the root directory, which will be disregarded when
 determining the source file name
 """
-def __init__(self, path, root="", verboseLog=None):
+def __init__(self, path: str, root: str = "", verbose_log=None):
 self.path = path
 self.root = root.rstrip("/\\")
-self.verboseLog = verboseLog
+self.verbose_log = verbose_log
 
 
 class AnalysisDiagnostic:
-def __init__(self, data, report, htmlReport):
+def __init__(self, data: Plist, report: "AnalysisReport",
+ html_report: Optional[str]):
 self._data = data
 self._loc = self._data['location']
 self._report = report
-self._htmlReport = htmlReport
-self._reportSize = len(self._data['path'])
+self._html_report = html_report
+self._report_size = len(self._data['path'])
 
-def getFileName(self):
+def get_file_name(self) -> str:
 root = self._report.run.root
-fileName = self._report.files[self._loc['file']]
-if fileName.startswith(root) and len(root) > 0:
-return fileName[len(root) + 1:]
-return fileName
+file_name = self._report.files[self._loc['file']]
+
+if file_name.startswith(root) and len(root) > 0:
+return file_name[len(root) + 1:]
 
-def getRootFileName(self):
+return file_name
+
+def get_root_file_name(self) -> str:
 path = self._data['path']
+
 if not path:
-return self.getFileName()
+return self.get_file_name()
+
 p = path[0]
 if 'location' in p:
-fIdx = p['location']['file']
+file_index = p['location']['file']
 else:  # control edge
-fIdx = path[0]['edges'][0]['start'][0]['file']
-out = self._report.files[fIdx]
+file_index = path[0]['edges'][0]['start'][0]['file']
+
+out = self._report.files[file_index]
 root = self._report.run.root
+
 if out.startswith(root):
 return out[len(root):]
+
 return out
 
-def getLine(self):
+def get_line(self) -> int:
 return self._loc['line']
 
-def getColumn(self):
+def get_column(self) -> int:
 return self._loc['col']
 
-def getPathLength(self):
-return self._reportSize
+def get_path_length(self) -> int:
+return self._report_size
 
-def getCategory(self):
+def get_category(self) -> str:
 return self._data['category']
 
-def getDescription(self):
+def get_description(self) -> str:
 return self._data['description']
 
-def getIssueIdentifier(self):
-id = self.getFileName() + "+"
-if 'issue_context' in self._data:
-id += self._data['issue_context'] + "+"
-if 'issue_hash_content_of_line_in_context' in self._data:
-id += str(self._data['issue_hash_content_of_line_in_context'])
+def get_issue_identifier(self) -> str:
+id = self.get_file_name() + "+"
+
+if "issue_context" in self._data:

[PATCH] D80514: [clang-tidy] modernize-use-trailing-return-type support for C++20 concepts and decltype

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



Comment at: 
clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp:399
 
-  return true;
+  return;
 }

Non needed. See readability-redundant-control-flow.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/modernize-use-trailing-return-type.rst:22
+  virtual float f3() const && = delete;virtual auto f3() const && -> float 
= delete;
+ 
===
 

bernhardmgruber wrote:
> I tried 2 online rst editors and they failed to format the code blocks inside 
> the tables. Will this work with the clang documentation?
In other documentation such examples are sequential. Same below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80514



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


[PATCH] D77474: [analyzer][MallocChecker] Make NewDeleteLeaks depend on DynamicMemoryModeling rather than NewDelete

2020-05-25 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

Looks good.




Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2024
+  if (!ChecksEnabled[CK_MallocChecker] && !ChecksEnabled[CK_NewDeleteChecker]) 
{
+C.addSink();
 return;

Szelethus wrote:
> martong wrote:
> > This seems to be inverse logic to me.
> > I'd expect that in a function called `Report...` we do stuff that is 
> > related to reporting only. That is why I think it would be better to have 
> > the condition and addSink before calling `Report...`. That way reporting 
> > and modeling would be even more separated.
> Very good point, but I think the actual problem lies in the name of the 
> method. `ReportBadFree` in particular is called from multiple places, and I 
> like how this is the function that takes over once we find a bug, because a 
> bad free (which in this context means the deallocation of a non-heap 
> allocated object) can never be a non-fatal error, so it make sense that the 
> sink is solved here.
Okay, makes sense, the new name fits this.


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

https://reviews.llvm.org/D77474



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


[PATCH] D78099: [analyzer][RetainCount] Tie diagnostics to osx.cocoa.RetainCount rather then RetainCountBase, for the most part

2020-05-25 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

LG!


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

https://reviews.llvm.org/D78099



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


[clang] 2b8d6fa - Revert "[PGO] Fix computation of function Hash"

2020-05-25 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-05-25T20:14:28+02:00
New Revision: 2b8d6fa0acacba4dee31ed618a5596414b2279d5

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

LOG: Revert "[PGO] Fix computation of function Hash"

This reverts commit 7c298c104bfe725d4315926a656263e8a5ac3054.
Fails make check-clang.

Failing Tests (8):
Clang :: Profile/c-counter-overflows.c
Clang :: Profile/c-general.c
Clang :: Profile/c-unprofiled-blocks.c
Clang :: Profile/cxx-rangefor.cpp
Clang :: Profile/cxx-throws.cpp
Clang :: Profile/misexpect-switch-default.c
Clang :: Profile/misexpect-switch-nonconst.c
Clang :: Profile/misexpect-switch.c

Added: 


Modified: 
clang/lib/CodeGen/CodeGenPGO.cpp

Removed: 
clang/test/Profile/c-collision.c



diff  --git a/clang/lib/CodeGen/CodeGenPGO.cpp 
b/clang/lib/CodeGen/CodeGenPGO.cpp
index 98827bc3eec5..3c91a04d5464 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -747,15 +747,13 @@ uint64_t PGOHash::finalize() {
 return Working;
 
   // Check for remaining work in Working.
-  if (Working) {
-using namespace llvm::support;
-uint64_t Swapped = endian::byte_swap(Working);
-MD5.update(llvm::makeArrayRef((uint8_t *), sizeof(Swapped)));
-  }
+  if (Working)
+MD5.update(Working);
 
   // Finalize the MD5 and return the hash.
   llvm::MD5::MD5Result Result;
   MD5.final(Result);
+  using namespace llvm::support;
   return Result.low();
 }
 

diff  --git a/clang/test/Profile/c-collision.c 
b/clang/test/Profile/c-collision.c
deleted file mode 100644
index fabecd752b4e..
--- a/clang/test/Profile/c-collision.c
+++ /dev/null
@@ -1,22 +0,0 @@
-// Test that a slight change in the code leads to a 
diff erent hash.
-// RUN: %clang_cc1 -UEXTRA -triple x86_64-unknown-linux-gnu -main-file-name 
c-collision.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s 
--check-prefix=CHECK-NOEXTRA
-// RUN: %clang_cc1 -DEXTRA -triple x86_64-unknown-linux-gnu -main-file-name 
c-collision.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s 
--check-prefix=CHECK-EXTRA
-
-// CHECK-NOEXTRA: @__profd_foo = private global { {{.*}} } { i64 
6699318081062747564, i64 7156072912471487002,
-// CHECK-EXTRA:   @__profd_foo = private global { {{.*}} } { i64 
6699318081062747564, i64 -4383447408116050035,
-
-extern int bar;
-void foo() {
-  if (bar) {
-  }
-  if (bar) {
-  }
-  if (bar) {
-if (bar) {
-#ifdef EXTRA
-  if (bar) {
-  }
-#endif
-}
-  }
-}



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


[PATCH] D79628: [Clang][Driver] Add Bounds and Thread to SupportsCoverage list

2020-05-25 Thread Marco Elver via Phabricator via cfe-commits
melver updated this revision to Diff 266054.
melver added a comment.

-triple -> -target


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79628

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/sanitize-coverage-bounds.c
  clang/test/CodeGen/sanitize-coverage-thread.c
  clang/test/Driver/fsanitize-coverage.c
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
  compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp
  compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp

Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp
@@ -1,7 +1,6 @@
 // Tests trace pc guard coverage collection.
 //
 // REQUIRES: has_sancovcc,stable-runtime,x86_64-linux
-// XFAIL: tsan
 //
 // RUN: DIR=%t_workdir
 // RUN: CLANG_ARGS="-O0 -fsanitize-coverage=trace-pc-guard"
Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp
@@ -1,7 +1,5 @@
 // Tests -fsanitize-coverage=stack-depth
 //
-// XFAIL: tsan
-//
 // RUN: %clangxx -O0 -std=c++11 -fsanitize-coverage=stack-depth %s -o %t
 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not Assertion{{.*}}failed
 // RUN: %clangxx -O0 -std=c++11 -fsanitize-coverage=trace-pc-guard,stack-depth \
Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp
@@ -2,7 +2,7 @@
 
 // REQUIRES: has_sancovcc,stable-runtime
 // UNSUPPORTED: i386-darwin
-// XFAIL: ubsan,tsan
+// XFAIL: ubsan
 // XFAIL: android && asan
 
 // RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=trace-pc,bb,no-prune 2>&1 | grep "call void @__sanitizer_cov_trace_pc" | count 3
Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
@@ -5,7 +5,6 @@
 //
 // RUN: %clangxx -O0 %s -fsanitize-coverage=inline-bool-flag,pc-table -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
-// XFAIL: tsan
 
 #include 
 #include 
Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp
@@ -5,7 +5,6 @@
 //
 // RUN: %clangxx -O0 %s -fsanitize-coverage=inline-8bit-counters,pc-table -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
-// XFAIL: tsan
 
 #include 
 #include 
Index: clang/test/Driver/fsanitize-coverage.c
===
--- clang/test/Driver/fsanitize-coverage.c
+++ clang/test/Driver/fsanitize-coverage.c
@@ -12,8 +12,10 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=kernel-memory -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=leak -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=bounds -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=bool -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=dataflow -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fsanitize-coverage=func,trace-pc %s 

[clang] 5bf2409 - [AIX] Add '-bcdtors:all:0:s' to linker to gather static init functions

2020-05-25 Thread Steven Wan via cfe-commits

Author: stevewan
Date: 2020-05-25T13:44:15-04:00
New Revision: 5bf2409a4e4d23018ecffe4eff39988a957e76f7

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

LOG: [AIX] Add '-bcdtors:all:0:s' to linker to gather static init functions

Summary: On AIX, add '-bcdtors:all:0:s' to the linker implicitly through the 
driver so that we can collect all static constructor and destructor functions.

Reviewers: hubert.reinterpretcast, Xiangling_L, ZarkoCA, daltenty

Reviewed By: hubert.reinterpretcast

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AIX.cpp
clang/test/Driver/aix-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 6fbff61f7656..df2e30da32a8 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -81,6 +81,7 @@ void aix::Linker::ConstructJob(Compilation , const 
JobAction ,
const InputInfoList , const ArgList 
,
const char *LinkingOutput) const {
   const AIX  = static_cast(getToolChain());
+  const Driver  = ToolChain.getDriver();
   ArgStringList CmdArgs;
 
   const bool IsArch32Bit = ToolChain.getTriple().isArch32Bit();
@@ -129,6 +130,12 @@ void aix::Linker::ConstructJob(Compilation , const 
JobAction ,
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
   }
 
+  // Collect all static constructor and destructor functions in CXX mode. This
+  // has to come before AddLinkerInputs as the implied option needs to precede
+  // any other '-bcdtors' settings or '-bnocdtors' that '-Wl' might forward.
+  if (D.CCCIsCXX())
+CmdArgs.push_back("-bcdtors:all:0:s");
+
   // Specify linker input file(s).
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 

diff  --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 95495718546c..218fbd2bb380 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -175,3 +175,21 @@
 // CHECK-LD64-NO-DEFAULT-LIBS: "-L[[SYSROOT]]/usr/lib" 
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lpthreads"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. 'bcdtors' and argument order.
+// RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \
+// RUN:  -Wl,-bnocdtors \
+// RUN:  -target powerpc-ibm-aix7.1.0.0 \
+// RUN:  --sysroot %S/Inputs/aix_ppc_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LD32-CXX-ARG-ORDER %s
+
+// CHECK-LD32-CXX-ARG-ORDER: {{.*}}clang{{.*}}" "-cc1" "-triple" 
"powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-CXX-ARG-ORDER: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32-CXX-ARG-ORDER: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD32-CXX-ARG-ORDER-NOT: "-bnso"
+// CHECK-LD32-CXX-ARG-ORDER: "-b32"
+// CHECK-LD32-CXX-ARG-ORDER: "-bpT:0x1000" "-bpD:0x2000"
+// CHECK-LD32-CXX-ARG-ORDER: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-CXX-ARG-ORDER: "-bcdtors:all:0:s"
+// CHECK-LD32-CXX-ARG-ORDER: "-bnocdtors"
+// CHECK-LD32-CXX-ARG-ORDER-NOT: "-bcdtors:all:0:s"



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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2020-05-25 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: clang/test/CodeGenCUDA/amdgpu-atomic-ops.cu:26
+  // CHECK: atomicrmw fsub double* {{.*}} monotonic
+  return __atomic_fetch_sub(p, 1.0, memory_order_relaxed);
+}

Nitpick, but this should be `1.0L` to be consistent.


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

https://reviews.llvm.org/D71726



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


[PATCH] D79628: [Clang][Driver] Add Bounds and Thread to SupportsCoverage list

2020-05-25 Thread Marco Elver via Phabricator via cfe-commits
melver updated this revision to Diff 266048.
melver added a comment.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

Address failing tests:

- Set -triple for test.
- Some existing tests now pass under TSAN, and can be enabled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79628

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/sanitize-coverage-bounds.c
  clang/test/CodeGen/sanitize-coverage-thread.c
  clang/test/Driver/fsanitize-coverage.c
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
  compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp
  compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp

Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp
@@ -1,7 +1,6 @@
 // Tests trace pc guard coverage collection.
 //
 // REQUIRES: has_sancovcc,stable-runtime,x86_64-linux
-// XFAIL: tsan
 //
 // RUN: DIR=%t_workdir
 // RUN: CLANG_ARGS="-O0 -fsanitize-coverage=trace-pc-guard"
Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp
@@ -1,7 +1,5 @@
 // Tests -fsanitize-coverage=stack-depth
 //
-// XFAIL: tsan
-//
 // RUN: %clangxx -O0 -std=c++11 -fsanitize-coverage=stack-depth %s -o %t
 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not Assertion{{.*}}failed
 // RUN: %clangxx -O0 -std=c++11 -fsanitize-coverage=trace-pc-guard,stack-depth \
Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp
@@ -2,7 +2,7 @@
 
 // REQUIRES: has_sancovcc,stable-runtime
 // UNSUPPORTED: i386-darwin
-// XFAIL: ubsan,tsan
+// XFAIL: ubsan
 // XFAIL: android && asan
 
 // RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=trace-pc,bb,no-prune 2>&1 | grep "call void @__sanitizer_cov_trace_pc" | count 3
Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
@@ -5,7 +5,6 @@
 //
 // RUN: %clangxx -O0 %s -fsanitize-coverage=inline-bool-flag,pc-table -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
-// XFAIL: tsan
 
 #include 
 #include 
Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp
@@ -5,7 +5,6 @@
 //
 // RUN: %clangxx -O0 %s -fsanitize-coverage=inline-8bit-counters,pc-table -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
-// XFAIL: tsan
 
 #include 
 #include 
Index: clang/test/Driver/fsanitize-coverage.c
===
--- clang/test/Driver/fsanitize-coverage.c
+++ clang/test/Driver/fsanitize-coverage.c
@@ -12,8 +12,10 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=kernel-memory -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=leak -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=bounds -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=bool -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=dataflow -fsanitize-coverage=func,trace-pc 

[PATCH] D80415: [AIX] Add '-bcdtors:all:0:s' to linker to gather static init functions

2020-05-25 Thread Steven Wan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5bf2409a4e4d: [AIX] Add -bcdtors:all:0:s to 
linker to gather static init functions (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80415

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -175,3 +175,21 @@
 // CHECK-LD64-NO-DEFAULT-LIBS: "-L[[SYSROOT]]/usr/lib" 
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lpthreads"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. 'bcdtors' and argument order.
+// RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \
+// RUN:  -Wl,-bnocdtors \
+// RUN:  -target powerpc-ibm-aix7.1.0.0 \
+// RUN:  --sysroot %S/Inputs/aix_ppc_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LD32-CXX-ARG-ORDER %s
+
+// CHECK-LD32-CXX-ARG-ORDER: {{.*}}clang{{.*}}" "-cc1" "-triple" 
"powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-CXX-ARG-ORDER: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32-CXX-ARG-ORDER: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD32-CXX-ARG-ORDER-NOT: "-bnso"
+// CHECK-LD32-CXX-ARG-ORDER: "-b32"
+// CHECK-LD32-CXX-ARG-ORDER: "-bpT:0x1000" "-bpD:0x2000"
+// CHECK-LD32-CXX-ARG-ORDER: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-CXX-ARG-ORDER: "-bcdtors:all:0:s"
+// CHECK-LD32-CXX-ARG-ORDER: "-bnocdtors"
+// CHECK-LD32-CXX-ARG-ORDER-NOT: "-bcdtors:all:0:s"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -81,6 +81,7 @@
const InputInfoList , const ArgList 
,
const char *LinkingOutput) const {
   const AIX  = static_cast(getToolChain());
+  const Driver  = ToolChain.getDriver();
   ArgStringList CmdArgs;
 
   const bool IsArch32Bit = ToolChain.getTriple().isArch32Bit();
@@ -129,6 +130,12 @@
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
   }
 
+  // Collect all static constructor and destructor functions in CXX mode. This
+  // has to come before AddLinkerInputs as the implied option needs to precede
+  // any other '-bcdtors' settings or '-bnocdtors' that '-Wl' might forward.
+  if (D.CCCIsCXX())
+CmdArgs.push_back("-bcdtors:all:0:s");
+
   // Specify linker input file(s).
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -175,3 +175,21 @@
 // CHECK-LD64-NO-DEFAULT-LIBS: "-L[[SYSROOT]]/usr/lib" 
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lpthreads"
 // CHECK-LD64-NO-DEFAULT-LIBS-NOT: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. 'bcdtors' and argument order.
+// RUN: %clangxx -no-canonical-prefixes %s 2>&1 -### \
+// RUN:  -Wl,-bnocdtors \
+// RUN:  -target powerpc-ibm-aix7.1.0.0 \
+// RUN:  --sysroot %S/Inputs/aix_ppc_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LD32-CXX-ARG-ORDER %s
+
+// CHECK-LD32-CXX-ARG-ORDER: {{.*}}clang{{.*}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-CXX-ARG-ORDER: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32-CXX-ARG-ORDER: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD32-CXX-ARG-ORDER-NOT: "-bnso"
+// CHECK-LD32-CXX-ARG-ORDER: "-b32"
+// CHECK-LD32-CXX-ARG-ORDER: "-bpT:0x1000" "-bpD:0x2000"
+// CHECK-LD32-CXX-ARG-ORDER: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-CXX-ARG-ORDER: "-bcdtors:all:0:s"
+// CHECK-LD32-CXX-ARG-ORDER: "-bnocdtors"
+// CHECK-LD32-CXX-ARG-ORDER-NOT: "-bcdtors:all:0:s"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -81,6 +81,7 @@
const InputInfoList , const ArgList ,
const char *LinkingOutput) const {
   const AIX  = static_cast(getToolChain());
+  const Driver  = ToolChain.getDriver();
   ArgStringList CmdArgs;
 
   const bool IsArch32Bit = ToolChain.getTriple().isArch32Bit();
@@ -129,6 +130,12 @@
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
   }
 
+  // Collect all static constructor and destructor functions in CXX mode. This
+  // has to come before AddLinkerInputs as the implied option needs to precede
+  // any other '-bcdtors' settings or '-bnocdtors' that '-Wl' might forward.
+  if (D.CCCIsCXX())
+CmdArgs.push_back("-bcdtors:all:0:s");
+
   // Specify linker input file(s).
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 

[PATCH] D80374: [Clang] Enable KF and KC mode for [_Complex] __float128

2020-05-25 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai updated this revision to Diff 266092.
nemanjai added a comment.

Remove handling for explicit `_Complex __float128`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80374

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/attr-mode.c

Index: clang/test/Sema/attr-mode.c
===
--- clang/test/Sema/attr-mode.c
+++ clang/test/Sema/attr-mode.c
@@ -4,6 +4,8 @@
 // RUN:   -verify %s
 // RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_64BIT_PPC64 -fsyntax-only \
 // RUN:   -verify %s
+// RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_F128_PPC64 -fsyntax-only \
+// RUN:   -verify -target-feature +float128 %s
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnux32 -DTEST_64BIT_X86 -fsyntax-only \
 // RUN:   -verify %s
 // RUN: %clang_cc1 -triple mips-linux-gnu -DTEST_MIPS_32 -fsyntax-only \
@@ -90,6 +92,13 @@
 void f_ft128_complex_arg(_Complex long double *x);
 void test_TFtype(f128ibm *a) { f_ft128_arg (a); }
 void test_TCtype(c128ibm *a) { f_ft128_complex_arg (a); }
+#elif TEST_F128_PPC64
+typedef _Complex float cf128 __attribute__ ((mode (KC)));
+typedef float f128 __attribute__ ((mode (KF)));
+void f_f128_arg(__float128 *x);
+void f_f128_complex_arg(_Complex __float128 *x);
+void test_KFtype(f128 *a) { f_f128_arg (a); }
+void test_KCtype(cf128 *a) { f_f128_complex_arg (a); }
 #elif TEST_MIPS_32
 typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
 int foo[sizeof(gcc_unwind_word) == 4 ? 1 : -1];
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -3942,7 +3942,8 @@
 /// parseModeAttrArg - Parses attribute mode string and returns parsed type
 /// attribute.
 static void parseModeAttrArg(Sema , StringRef Str, unsigned ,
- bool , bool ) {
+ bool , bool ,
+ bool ) {
   IntegerMode = true;
   ComplexMode = false;
   switch (Str.size()) {
@@ -3963,7 +3964,12 @@
 case 'X':
   DestWidth = 96;
   break;
+case 'K': // KFmode - IEEE quad precision (__float128)
+  ExplicitIEEE = true;
+  DestWidth = 128;
+  break;
 case 'T':
+  ExplicitIEEE = false;
   DestWidth = 128;
   break;
 }
@@ -4024,6 +4030,7 @@
   unsigned DestWidth = 0;
   bool IntegerMode = true;
   bool ComplexMode = false;
+  bool ExplicitIEEE = false;
   llvm::APInt VectorSize(64, 0);
   if (Str.size() >= 4 && Str[0] == 'V') {
 // Minimal length of vector mode is 4: 'V' + NUMBER(>=1) + TYPE(>=2).
@@ -4036,7 +4043,7 @@
 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
 VectorSize.isPowerOf2()) {
   parseModeAttrArg(*this, Str.substr(VectorStringLength + 1), DestWidth,
-   IntegerMode, ComplexMode);
+   IntegerMode, ComplexMode, ExplicitIEEE);
   // Avoid duplicate warning from template instantiation.
   if (!InInstantiation)
 Diag(AttrLoc, diag::warn_vector_mode_deprecated);
@@ -4046,7 +4053,8 @@
   }
 
   if (!VectorSize)
-parseModeAttrArg(*this, Str, DestWidth, IntegerMode, ComplexMode);
+parseModeAttrArg(*this, Str, DestWidth, IntegerMode, ComplexMode,
+ ExplicitIEEE);
 
   // FIXME: Sync this with InitializePredefinedMacros; we need to match int8_t
   // and friends, at least with glibc.
@@ -4112,7 +4120,7 @@
 NewElemTy = Context.getIntTypeForBitwidth(DestWidth,
   OldElemTy->isSignedIntegerType());
   else
-NewElemTy = Context.getRealTypeForBitwidth(DestWidth);
+NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitIEEE);
 
   if (NewElemTy.isNull()) {
 Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -265,7 +265,8 @@
   return NoInt;
 }
 
-TargetInfo::RealType TargetInfo::getRealTypeByWidth(unsigned BitWidth) const {
+TargetInfo::RealType TargetInfo::getRealTypeByWidth(unsigned BitWidth,
+bool ExplicitIEEE) const {
   if (getFloatWidth() == BitWidth)
 return Float;
   if (getDoubleWidth() == BitWidth)
@@ -277,6 +278,10 @@
   return LongDouble;
 break;
   case 128:
+// The caller explicitly asked for an IEEE compliant type but we still
+// have to check if the target supports it.
+if (ExplicitIEEE)
+  return hasFloat128Type() ? Float128 : NoFloat;
 if (() == ::APFloat::PPCDoubleDouble() ||
 () 

[PATCH] D80533: [Clang] Enable _Complex __float

2020-05-25 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai created this revision.
nemanjai added reviewers: rjmccall, rsmith, PowerPC.
Herald added a subscriber: kbarton.
Herald added a project: clang.

When I added `__float128` a while ago, I neglected to add support for the 
complex variant of the type. This patch just adds that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80533

Files:
  clang/lib/Sema/DeclSpec.cpp
  clang/test/CodeGen/ppc64-complex-parms.c
  clang/test/CodeGen/ppc64-complex-return.c


Index: clang/test/CodeGen/ppc64-complex-return.c
===
--- clang/test/CodeGen/ppc64-complex-return.c
+++ clang/test/CodeGen/ppc64-complex-return.c
@@ -1,9 +1,20 @@
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -target-feature +float128 -DTEST_F128 -triple \
+// RUN:   powerpc64le-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s \
+// RUN:   --check-prefix CHECK-F128
 
 float crealf(_Complex float);
 double creal(_Complex double);
 long double creall(_Complex long double);
+#ifdef TEST_F128
+__float128 crealf128(_Complex __float128);
+_Complex __float128 foo_f128(_Complex __float128 x) {
+  return x;
+}
+
+// CHECK-F128: define { fp128, fp128 } @foo_f128(fp128 {{[%A-Za-z0-9.]+}}, 
fp128 {{[%A-Za-z0-9.]+}}) [[NUW:#[0-9]+]] {
+#endif
 
 _Complex float foo_float(_Complex float x) {
   return x;
@@ -80,6 +91,17 @@
 // CHECK: extractvalue { ppc_fp128, ppc_fp128 } [[VAR3]], 0
 // CHECK: extractvalue { ppc_fp128, ppc_fp128 } [[VAR3]], 1
 
+#ifdef TEST_F128
+__float128 bar_f128(void) {
+  return crealf128(foo_f128(2.0Q - 2.5Qi));
+}
+
+// CHECK-F128: define fp128 @bar_f128() [[NUW]] {
+// CHECK-F128: [[VAR3:[%A-Za-z0-9.]+]] = call { fp128, fp128 } @foo_f128
+// CHECK-F128: extractvalue { fp128, fp128 } [[VAR3]], 0
+// CHECK-F128: extractvalue { fp128, fp128 } [[VAR3]], 1
+#endif
+
 int bar_int(void) {
   return __real__(foo_int(2 - 3i));
 }
Index: clang/test/CodeGen/ppc64-complex-parms.c
===
--- clang/test/CodeGen/ppc64-complex-parms.c
+++ clang/test/CodeGen/ppc64-complex-parms.c
@@ -1,8 +1,19 @@
+// REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -target-feature +float128 -DTEST_F128 -triple \
+// RUN:   powerpc64le-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s \
+// RUN:   --check-prefix CHECK-F128
 
 float crealf(_Complex float);
 double creal(_Complex double);
 long double creall(_Complex long double);
+#ifdef TEST_F128
+__float128 crealf128(_Complex __float128);
+__float128 foo_f128(_Complex __float128 x) {
+  return crealf128(x);
+}
+// CHECK-F128: define fp128 @foo_f128(fp128 {{[%A-Za-z0-9.]+}}, fp128 
{{[%A-Za-z0-9.]+}})
+#endif
 
 float foo_float(_Complex float x) {
   return crealf(x);
Index: clang/lib/Sema/DeclSpec.cpp
===
--- clang/lib/Sema/DeclSpec.cpp
+++ clang/lib/Sema/DeclSpec.cpp
@@ -1269,7 +1269,8 @@
   // Note that this intentionally doesn't include _Complex _Bool.
   if (!S.getLangOpts().CPlusPlus)
 S.Diag(TSTLoc, diag::ext_integer_complex);
-} else if (TypeSpecType != TST_float && TypeSpecType != TST_double) {
+} else if (TypeSpecType != TST_float && TypeSpecType != TST_double &&
+   TypeSpecType != TST_float128) {
   S.Diag(TSCLoc, diag::err_invalid_complex_spec)
 << getSpecifierName((TST)TypeSpecType, Policy);
   TypeSpecComplex = TSC_unspecified;


Index: clang/test/CodeGen/ppc64-complex-return.c
===
--- clang/test/CodeGen/ppc64-complex-return.c
+++ clang/test/CodeGen/ppc64-complex-return.c
@@ -1,9 +1,20 @@
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -target-feature +float128 -DTEST_F128 -triple \
+// RUN:   powerpc64le-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s \
+// RUN:   --check-prefix CHECK-F128
 
 float crealf(_Complex float);
 double creal(_Complex double);
 long double creall(_Complex long double);
+#ifdef TEST_F128
+__float128 crealf128(_Complex __float128);
+_Complex __float128 foo_f128(_Complex __float128 x) {
+  return x;
+}
+
+// CHECK-F128: define { fp128, fp128 } @foo_f128(fp128 {{[%A-Za-z0-9.]+}}, fp128 {{[%A-Za-z0-9.]+}}) [[NUW:#[0-9]+]] {
+#endif
 
 _Complex float foo_float(_Complex float x) {
   return x;
@@ -80,6 +91,17 @@
 // CHECK: extractvalue { ppc_fp128, ppc_fp128 } [[VAR3]], 0
 // CHECK: extractvalue { ppc_fp128, ppc_fp128 } [[VAR3]], 1
 
+#ifdef TEST_F128
+__float128 bar_f128(void) {
+  return crealf128(foo_f128(2.0Q - 2.5Qi));
+}
+
+// CHECK-F128: define fp128 @bar_f128() [[NUW]] {
+// CHECK-F128: [[VAR3:[%A-Za-z0-9.]+]] = call { fp128, fp128 } @foo_f128
+// 

[PATCH] D80374: [Clang] Enable KF and KC mode for [_Complex] __float128

2020-05-25 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

The support for `_Complex __float128` in https://reviews.llvm.org/D80533
I will repurpose leave only the addition of the `KF/KC` modes in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80374



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


[PATCH] D69585: Add option to instantiate templates already in the PCH

2020-05-25 Thread Reid "Away June-Sep" Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5610
+  if (Args.hasFlag(options::OPT_fpch_instantiate_templates,
+   options::OPT_fno_pch_instantiate_templates, false))
+CmdArgs.push_back("-fpch-instantiate-templates");

llunak wrote:
> rnk wrote:
> > Does MSVC default to this behavior? Should this default to true with 
> > clang-cl /Yu / /Yc? This can be future work and does not need to be part of 
> > this patch.
> Since MSVC is noticeably faster for an equivalent PCH compile than current 
> Clang, presumably it instantiates templates already in the PCH. But that 
> doesn't really matter for this patch, if it were ok to enable this by default 
> for clang-cl, than it would be ok also for clang itself. That cannot be done 
> now though, https://reviews.llvm.org/D69585#1946765 points out a corner case 
> where this change makes a valid compilation error out, and that's the reason 
> for having this behind a flag. I expect Clang could possibly be adjusted to 
> bail out and delay template instantiantion in such a case until it can be 
> performed successfully, but given the response rate to my PCH patches I first 
> wanted to get the feature in somehow, and I can try to make the flag 
> default/irrelevant later.
> 
Right, I guess what I mean is, for that example where instantiation at the end 
of the PCH creates an error, does MSVC emit an error? I just checked, and it 
looks like the answer is yes, so it seems like we could make this the default 
behavior for `clang-cl /Yc` without much further discussion.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69585



___
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-05-25 Thread Raul Tambre via Phabricator via cfe-commits
tambre updated this revision to Diff 265872.
tambre marked 4 inline comments as done.
tambre added a comment.

Remove memcpy overload tests from warn-fortify-source.c, which relied on 
identifier-based builtin identification.


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/IdentifierTable.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/AST/ast-dump-attr.cpp
  clang/test/CodeGen/builtin-redeclaration.c
  clang/test/CodeGen/callback_pthread_create.c
  clang/test/CodeGen/ms-intrinsics.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
@@ -60,12 +60,15 @@
 
 extern float fmaxf(float, float);
 
-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 .}}
+typedef struct __jmp_buf_tag {
+} sigjmp_buf[1];
 
-// CHECK: FunctionDecl {{.*}}  col:6 sigsetjmp '
+int sigsetjmp(struct __jmp_buf_tag[1], int);
+
+// CHECK: FunctionDecl {{.*}}  col:5 implicit sigsetjmp '
+// CHECK: FunctionDecl {{.*}}  col:5 sigsetjmp '
 // 

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

2020-05-25 Thread Raul Tambre via Phabricator via cfe-commits
tambre updated this revision to Diff 265871.
tambre marked 6 inline comments as done.
tambre added a comment.

Weakened noexcept checking.


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/IdentifierTable.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/AST/ast-dump-attr.cpp
  clang/test/CodeGen/builtin-redeclaration.c
  clang/test/CodeGen/callback_pthread_create.c
  clang/test/CodeGen/ms-intrinsics.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,10 +1,12 @@
 // 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
 
+// FIXME: Incompatible builtin redeclarations aren't considered builtins and thus don't call the builtin nor inherit their attributes.
+// %clang_cc1 -triple x86_64-apple-macosx10.14.0 %s -verify -DUSE_PASS_OBJECT_SIZE
+// %clang_cc1 -xc++ -triple x86_64-apple-macosx10.14.0 %s -verify -DUSE_PASS_OBJECT_SIZE
+
 typedef unsigned long size_t;
 
 #ifdef __cplusplus
Index: clang/test/Sema/implicit-builtin-decl.c
===
--- clang/test/Sema/implicit-builtin-decl.c
+++ clang/test/Sema/implicit-builtin-decl.c
@@ -60,12 +60,15 @@
 
 extern float fmaxf(float, float);
 
-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 .}}
+typedef struct __jmp_buf_tag {
+} sigjmp_buf[1];
 
-// CHECK: FunctionDecl {{.*}}  col:6 sigsetjmp '
+int sigsetjmp(struct __jmp_buf_tag[1], int);
+
+// CHECK: FunctionDecl {{.*}}  col:5 implicit sigsetjmp '
+// CHECK: FunctionDecl {{.*}}  col:5 sigsetjmp '
 // CHECK-NOT: FunctionDecl
-// CHECK: ReturnsTwiceAttr {{.*}} <{{.*}}> Implicit
+// CHECK: ReturnsTwiceAttr {{.*}} <{{.*}}> Inherited Implicit
 
 // PR40692
 void pthread_create(); // no warning expected
Index: clang/test/CodeGen/ms-intrinsics.c
===
--- clang/test/CodeGen/ms-intrinsics.c
+++ clang/test/CodeGen/ms-intrinsics.c
@@ -17,6 +17,7 @@
 
 #include 
 
+// FIXME: Why aren't these builtins recognized as builtins?
 #if defined(__i386__) || defined(__x86_64__)
 void test__stosb(unsigned char *Dest, unsigned char Data, size_t Count) {
   return __stosb(Dest, Data, Count);
Index: clang/test/CodeGen/callback_pthread_create.c
===
--- clang/test/CodeGen/callback_pthread_create.c
+++ clang/test/CodeGen/callback_pthread_create.c
@@ -14,6 +14,7 @@
 typedef __darwin_pthread_t pthread_t;
 typedef __darwin_pthread_attr_t pthread_attr_t;
 
+// FIXME: Why isn't this 

[PATCH] D69585: Add option to instantiate templates already in the PCH

2020-05-25 Thread Luboš Luňák via Phabricator via cfe-commits
llunak marked an inline comment as done.
llunak added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5610
+  if (Args.hasFlag(options::OPT_fpch_instantiate_templates,
+   options::OPT_fno_pch_instantiate_templates, false))
+CmdArgs.push_back("-fpch-instantiate-templates");

rnk wrote:
> Does MSVC default to this behavior? Should this default to true with clang-cl 
> /Yu / /Yc? This can be future work and does not need to be part of this patch.
Since MSVC is noticeably faster for an equivalent PCH compile than current 
Clang, presumably it instantiates templates already in the PCH. But that 
doesn't really matter for this patch, if it were ok to enable this by default 
for clang-cl, than it would be ok also for clang itself. That cannot be done 
now though, https://reviews.llvm.org/D69585#1946765 points out a corner case 
where this change makes a valid compilation error out, and that's the reason 
for having this behind a flag. I expect Clang could possibly be adjusted to 
bail out and delay template instantiantion in such a case until it can be 
performed successfully, but given the response rate to my PCH patches I first 
wanted to get the feature in somehow, and I can try to make the flag 
default/irrelevant later.



Repository:
  rC Clang

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

https://reviews.llvm.org/D69585



___
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-05-25 Thread Raul Tambre via Phabricator via cfe-commits
tambre added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:8880
+  }
+}
+

rjmccall wrote:
> tambre wrote:
> > rjmccall wrote:
> > > Hmm.  I'm concerned about not doing any sort of semantic compatibility 
> > > check here before we assign the function special semantics.  Have we 
> > > really never done those in C++?
> > > 
> > > If not, I wonder if we can reasonably make an implicit declaration but 
> > > just make it hidden from lookup.
> > Currently there's no semantic compatibility checking for builtin 
> > redeclarations. There is for initial declarations though.
> > 
> > I've added this checking by splitting the actual builtin declaration 
> > creation off from `LazilyCreateBuiltin` into `CreateBuiltin` and checking 
> > if the current declaration is compatible with what the builtin's would be.
> > This results in stronger typechecking than before for builtin declarations, 
> > so some incompatible declarations are no longer marked as builtin. See 
> > `cxx1z-noexcept-function-type.cpp` for an example.
> That makes sense to me in principle.  I'm definitely concerned about 
> `noexcept` differences causing C library functions to not be treated as 
> builtins, though; that seems stricter than we want.  How reasonable is it to 
> weaken this?
I agree having `noexcept` weakened is reasonable.
I've changed it to create an identical type to the NewFD with the exception 
spec removed for the comparison. This fixes it.



Comment at: clang/test/CodeGen/ms-intrinsics.c:23
 void test__stosb(unsigned char *Dest, unsigned char Data, size_t Count) {
   return __stosb(Dest, Data, Count);
 }

`__stosb` and friends aren't marked as builtin because they're declared as 
`static`.
I don't think there's a good reason to have builtins as `static` and we should 
simply remove the `static` specifier from those intrinsics in headers.
Alternatively, we could weaken compatibility checking similar to `noexcept`.
Thoughts?



Comment at: clang/test/Sema/warn-fortify-source.c:20
 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)) {

rjmccall wrote:
> tambre wrote:
> > Not quite sure what to do here. These were previously recognized as 
> > builtins due to their name despite being incompatible and thus had fortify 
> > checking similar to the real `memcpy`.
> > 
> > Maybe:
> > 1. Introduce a generic version of `ArmBuiltinAliasAttr`.
> > 2. Something like `FormatAttr`.
> That's interesting.  It definitely seems wrong to apply builtin logic to a 
> function that doesn't have a compatible low-level signature.  My inclination 
> is to disable builtin checking here, but to notify the contributors so that 
> they can figure out an appropriate response.
Agreed.
I've removed this test, as there doesn't seem to be an easy way to replicate 
this behaviour.



Comment at: clang/test/SemaCXX/cxx1z-noexcept-function-type.cpp:120
   extern "C" int strcmp(const char *, const char *);
-  extern "C" int strncmp(const char *, const char *, decltype(sizeof(0))) 
noexcept;
+  extern "C" int strncmp(const char *, const char *, decltype(sizeof(0)));
 

tambre wrote:
> This doesn't work anymore since we now properly check builtin declaration 
> compatibility and since C++17 noexcept is part of the function type but 
> builtins aren't noexcept.
> Thoughts?
Fixed by removing `noexcept` for the declaration compatibility comparison.


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] D80472: [clangd] Add access specifier information to hover contents

2020-05-25 Thread Daniel Martín via Phabricator via cfe-commits
danielmartin created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.
danielmartin edited the summary of this revision.

For https://github.com/clangd/clangd/issues/382

This commit adds access specifier information to the hover
contents. For example, the hover information of a class field or
member function will now indicate if the field or member is private,
public, or protected. This can be particularly useful when a developer
is in the implementation file and wants to know if a particular member
definition is public or private.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80472

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -12,6 +12,7 @@
 #include "TestIndex.h"
 #include "TestTU.h"
 #include "index/MemIndex.h"
+#include "clang/Basic/Specifiers.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/StringRef.h"
@@ -1964,7 +1965,51 @@
 // In test::Bar
 def)",
   },
-  };
+  {
+  [](HoverInfo ) {
+HI.Kind = index::SymbolKind::Field;
+HI.AccessSpecifier = AccessSpecifier::AS_public;
+HI.Name = "foo";
+HI.LocalScope = "test::Bar::";
+HI.Definition = "def";
+  },
+  R"(public field foo
+
+// In test::Bar
+def)",
+  },
+  {
+  [](HoverInfo ) {
+HI.Definition = "int method()";
+HI.AccessSpecifier = AccessSpecifier::AS_protected;
+HI.Kind = index::SymbolKind::InstanceMethod;
+HI.NamespaceScope = "";
+HI.LocalScope = "cls::";
+HI.Name = "method";
+HI.Parameters.emplace();
+HI.ReturnType = "int";
+HI.Type = "int ()";
+  },
+  R"(protected instance-method method
+
+→ int
+
+// In cls
+int method())",
+  },
+  {
+  [](HoverInfo ) {
+HI.Kind = index::SymbolKind::Union;
+HI.AccessSpecifier = AccessSpecifier::AS_private;
+HI.Name = "foo";
+HI.NamespaceScope = "ns1::";
+HI.Definition = "union foo {}";
+  },
+  R"(private union foo
+
+// In namespace ns1
+union foo {})",
+  }};
 
   for (const auto  : Cases) {
 HoverInfo HI;
Index: clang-tools-extra/clangd/Hover.h
===
--- clang-tools-extra/clangd/Hover.h
+++ clang-tools-extra/clangd/Hover.h
@@ -59,6 +59,8 @@
   /// Source code containing the definition of the symbol.
   std::string Definition;
 
+  /// Access specifier. Applies to members of class/structs or unions.
+  AccessSpecifier AccessSpecifier = AccessSpecifier::AS_none;
   /// Pretty-printed variable type.
   /// Set only for variables.
   llvm::Optional Type;
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -468,6 +468,7 @@
   HoverInfo HI;
   const ASTContext  = D->getASTContext();
 
+  HI.AccessSpecifier = D->getAccess();
   HI.NamespaceScope = getNamespaceScope(D);
   if (!HI.NamespaceScope->empty())
 HI.NamespaceScope->append("::");
@@ -676,6 +677,20 @@
   }
 }
 
+StringRef getAccessString(AccessSpecifier AS) {
+  switch (AS) {
+  case AccessSpecifier::AS_public:
+return "public";
+  case AccessSpecifier::AS_protected:
+return "protected";
+  case AccessSpecifier::AS_private:
+return "private";
+  case AccessSpecifier::AS_none:
+return {};
+  }
+  llvm_unreachable("Unknown AccessSpecifier");
+}
+
 } // namespace
 
 llvm::Optional getHover(ParsedAST , Position Pos,
@@ -774,6 +789,8 @@
   // level 1 and 2 headers in a huge font, see
   // https://github.com/microsoft/vscode/issues/88417 for details.
   markup::Paragraph  = Output.addHeading(3);
+  if (AccessSpecifier != AccessSpecifier::AS_none)
+Header.appendText(getAccessString(AccessSpecifier)).appendSpace();
   if (Kind != index::SymbolKind::Unknown)
 Header.appendText(index::getSymbolKindString(Kind)).appendSpace();
   assert(!Name.empty() && "hover triggered on a nameless symbol");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80425: Fix LLVM/Clang builds with mingw toolchain

2020-05-25 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 added inline comments.



Comment at: llvm/cmake/modules/HandleLLVMOptions.cmake:967
CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
-  elseif(LINKER_IS_LLD_LINK)
+  elseif(LINKER_IS_LLD_LINK AND NOT MINGW)
 append("/lldltocache:${PROJECT_BINARY_DIR}/lto.cache"

mstorsjo wrote:
> mati865 wrote:
> > mstorsjo wrote:
> > > mati865 wrote:
> > > > thieta wrote:
> > > > > mstorsjo wrote:
> > > > > > Do you happen to know why `LINKER_IS_LLD_LINK` gets set in this 
> > > > > > case? `ld.lld` (the ELF linker interface, which then the MinGW 
> > > > > > driver remaps onto the COFF backend with the `lld-link` interface) 
> > > > > > certainly doesn't take `lld-link` style options. I believe (without 
> > > > > > diving further into it) that we shouldn't be setting this flag in 
> > > > > > this combination, but with the option implemented, we should fit it 
> > > > > > into the case further above, `elseif((UNIX OR MINGW) AND 
> > > > > > LLVM_USE_LINKER STREQUAL "lld")`
> > > > > Yeah I bet that variable is set because I pass `LLVM_USE_LINKER=lld` 
> > > > > but I haven't digged to deeply. I can rework the if statement here 
> > > > > when we have the lld option in there.
> > > > > Yeah I bet that variable is set because I pass LLVM_USE_LINKER=lld 
> > > > > but I haven't digged to deeply. 
> > > > 
> > > > It does use `lld-link` when you use `LLVM_USE_LINKER=lld`.
> > > > 
> > > > The problem lies in this line:
> > > > ```
> > > > append("/lldltocache:${PROJECT_BINARY_DIR}/lto.cache"
> > > > ```
> > > > For MinGW that should read:
> > > > ```
> > > > append("-Wl,/lldltocache:${PROJECT_BINARY_DIR}/lto.cache"
> > > > ```
> > > > That's because you are passing this flag to GCC/Clang.
> > > > For MinGW that should read:
> > > > 
> > > > append("-Wl,/lldltocache:${PROJECT_BINARY_DIR}/lto.cache"
> > > 
> > > We're adding this option properly in the mingw frontend, so we shouldn't 
> > > do the hacky way of passing lld-link options via the mingw frontend by 
> > > passing them as `/option`.
> > > 
> > > And the reason `LINKER_IS_LLD_LINK` is set seems to be this:
> > > 
> > > ```
> > > if(CMAKE_LINKER MATCHES "lld-link" OR (WIN32 AND LLVM_USE_LINKER STREQUAL 
> > > "lld") OR LLVM_ENABLE_LLD)
> > > ```
> > > 
> > > Perhaps that should be changed into
> > > 
> > > ```
> > > if(CMAKE_LINKER MATCHES "lld-link" OR (WIN32 AND LLVM_USE_LINKER STREQUAL 
> > > "lld" AND NOT MINGW) OR LLVM_ENABLE_LLD)
> > > ```
> > > 
> > > We're adding this option properly in the mingw frontend, so we shouldn't 
> > > do the hacky way of passing lld-link options via the mingw frontend by 
> > > passing them as /option.
> > 
> > I was about to add that and one more LTO related option but thought "what 
> > if LLVM should link with lld-link on MinGW?" and eventually forgot about it.
> > 
> > 
> > 
> > > And the reason LINKER_IS_LLD_LINK is set seems to be this:
> > > ```
> > > if(CMAKE_LINKER MATCHES "lld-link" OR (WIN32 AND LLVM_USE_LINKER STREQUAL 
> > > "lld") OR LLVM_ENABLE_LLD)
> > > ```
> > > Perhaps that should be changed into
> > > ```
> > > if(CMAKE_LINKER MATCHES "lld-link" OR (WIN32 AND LLVM_USE_LINKER STREQUAL 
> > > "lld" AND NOT MINGW) OR LLVM_ENABLE_LLD)
> > > ```
> > 
> > It won't work if somebody uses `LLVM_ENABLE_LLD=ON` instead of 
> > `LLVM_USE_LINKER=lld` which is supposed to be equivalent.
> > That raises question how `LLVM_ENABLE_LLD=ON` does even work on UNIX 
> > platforms.
> > 
> > IMO this would be better:
> > ```
> > if(CMAKE_LINKER MATCHES "lld-link" OR MSVC AND (LLVM_USE_LINKER STREQUAL 
> > "lld" OR LLVM_ENABLE_LLD))
> > ```
> > I was about to add that and one more LTO related option but thought "what 
> > if LLVM should link with lld-link on MinGW?" and eventually forgot about it.
> 
> I don't think that really is a supposedly supported setup - lld-link wouldn't 
> find any libs to link against etc, as the compiler driver is supposed to pass 
> those as `-L` options in mingw/unix style tools.
> 
> > It won't work if somebody uses LLVM_ENABLE_LLD=ON instead of 
> > LLVM_USE_LINKER=lld which is supposed to be equivalent.
> > That raises question how LLVM_ENABLE_LLD=ON does even work on UNIX 
> > platforms.
> 
> Either it doesn't work and nobody actually use it that way, or the effects of 
> `LINKER_IS_LLD_LINK` are mostly harmless.
> 
> > IMO this would be better:
> > 
> > `if(CMAKE_LINKER MATCHES "lld-link" OR MSVC AND (LLVM_USE_LINKER STREQUAL 
> > "lld" OR LLVM_ENABLE_LLD))`
> 
> Yeah, that looks sensible.
> I don't think that really is a supposedly supported setup - lld-link wouldn't 
> find any libs to link against etc, as the compiler driver is supposed to pass 
> those as -L options in mingw/unix style tools.

Well, it worked both ways (`lld-link` and `ld.lld`) with slight changes to 
CMake files when using your toolchain ;)


Repository:
  rG LLVM Github Monorepo

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


[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

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

switch function to unsigned


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

https://reviews.llvm.org/D79773

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13537,6 +13537,7 @@
   CHECK_PARSE_BOOL(AlignConsecutiveBitFields);
   CHECK_PARSE_BOOL(AlignConsecutiveDeclarations);
   CHECK_PARSE_BOOL(AlignConsecutiveMacros);
+  CHECK_PARSE_BOOL(AlwaysBreakBeforeConceptDeclarations);
   CHECK_PARSE_BOOL(AllowAllArgumentsOnNextLine);
   CHECK_PARSE_BOOL(AllowAllConstructorInitializersOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
@@ -13557,6 +13558,7 @@
   CHECK_PARSE_BOOL(IndentCaseLabels);
   CHECK_PARSE_BOOL(IndentCaseBlocks);
   CHECK_PARSE_BOOL(IndentGotoLabels);
+  CHECK_PARSE_BOOL(IndentRequires);
   CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
   CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
   CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);
@@ -16567,6 +16569,223 @@
"}",
Style);
 }
+
+TEST_F(FormatTest, ConceptsAndRequires) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+
+  verifyFormat("template \n"
+   "concept Hashable = requires(T a) {\n"
+   "  { std::hash{}(a) } -> std::convertible_to;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "  { a != b } -> bool;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "  { a != b } -> bool;\n"
+   "};",
+   Style);
+
+  verifyFormat("template \n"
+   "requires Iterator\n"
+   "void sort(It begin, It end) {\n"
+   "  //\n"
+   "}",
+   Style);
+
+  verifyFormat("template \n"
+   "concept Large = sizeof(T) > 10;",
+   Style);
+
+  verifyFormat("template \n"
+   "concept FooableWith = requires(T t, U u) {\n"
+   "  typename T::foo_type;\n"
+   "  { t.foo(u) } -> typename T::foo_type;\n"
+   "  t++;\n"
+   "};\n"
+   "void doFoo(FooableWith auto t) {\n"
+   "  t.foo(3);\n"
+   "}",
+   Style);
+  verifyFormat("template \n"
+   "concept Context = sizeof(T) == 1;",
+   Style);
+  verifyFormat("template \n"
+   "concept Context = is_specialization_of_v;",
+   Style);
+  verifyFormat("template \n"
+   "concept Node = std::is_object_v;",
+   Style);
+  verifyFormat("template \n"
+   "concept Tree = true;",
+   Style);
+
+  verifyFormat("template  int g(T i) requires Concept1 {\n"
+   "  //...\n"
+   "}",
+   Style);
+
+  verifyFormat(
+  "template  int g(T i) requires Concept1 && Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat(
+  "template  int g(T i) requires Concept1 || Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat("template \n"
+   "veryveryvery_long_return_type g(T i) requires Concept1 || "
+   "Concept2 {\n"
+   "  //...\n"
+   "}",
+   Style);
+
+  verifyFormat("template \n"
+   "veryveryvery_long_return_type g(T i) requires Concept1 && "
+   "Concept2 {\n"
+   "  //...\n"
+   "}",
+   Style);
+
+  verifyFormat(
+  "template \n"
+  "veryveryvery_long_return_type g(T i) requires Concept1 && Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat(
+  "template \n"
+  "veryveryvery_long_return_type g(T i) requires Concept1 || Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat("template \n"
+   "requires Foo() && Bar {\n"
+   "  //\n"
+   "}",
+   Style);
+
+  verifyFormat("template \n"
+ 

[PATCH] D80425: Fix LLVM/Clang builds with mingw toolchain

2020-05-25 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: llvm/cmake/modules/HandleLLVMOptions.cmake:967
CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
-  elseif(LINKER_IS_LLD_LINK)
+  elseif(LINKER_IS_LLD_LINK AND NOT MINGW)
 append("/lldltocache:${PROJECT_BINARY_DIR}/lto.cache"

mati865 wrote:
> mstorsjo wrote:
> > mati865 wrote:
> > > thieta wrote:
> > > > mstorsjo wrote:
> > > > > Do you happen to know why `LINKER_IS_LLD_LINK` gets set in this case? 
> > > > > `ld.lld` (the ELF linker interface, which then the MinGW driver 
> > > > > remaps onto the COFF backend with the `lld-link` interface) certainly 
> > > > > doesn't take `lld-link` style options. I believe (without diving 
> > > > > further into it) that we shouldn't be setting this flag in this 
> > > > > combination, but with the option implemented, we should fit it into 
> > > > > the case further above, `elseif((UNIX OR MINGW) AND LLVM_USE_LINKER 
> > > > > STREQUAL "lld")`
> > > > Yeah I bet that variable is set because I pass `LLVM_USE_LINKER=lld` 
> > > > but I haven't digged to deeply. I can rework the if statement here when 
> > > > we have the lld option in there.
> > > > Yeah I bet that variable is set because I pass LLVM_USE_LINKER=lld but 
> > > > I haven't digged to deeply. 
> > > 
> > > It does use `lld-link` when you use `LLVM_USE_LINKER=lld`.
> > > 
> > > The problem lies in this line:
> > > ```
> > > append("/lldltocache:${PROJECT_BINARY_DIR}/lto.cache"
> > > ```
> > > For MinGW that should read:
> > > ```
> > > append("-Wl,/lldltocache:${PROJECT_BINARY_DIR}/lto.cache"
> > > ```
> > > That's because you are passing this flag to GCC/Clang.
> > > For MinGW that should read:
> > > 
> > > append("-Wl,/lldltocache:${PROJECT_BINARY_DIR}/lto.cache"
> > 
> > We're adding this option properly in the mingw frontend, so we shouldn't do 
> > the hacky way of passing lld-link options via the mingw frontend by passing 
> > them as `/option`.
> > 
> > And the reason `LINKER_IS_LLD_LINK` is set seems to be this:
> > 
> > ```
> > if(CMAKE_LINKER MATCHES "lld-link" OR (WIN32 AND LLVM_USE_LINKER STREQUAL 
> > "lld") OR LLVM_ENABLE_LLD)
> > ```
> > 
> > Perhaps that should be changed into
> > 
> > ```
> > if(CMAKE_LINKER MATCHES "lld-link" OR (WIN32 AND LLVM_USE_LINKER STREQUAL 
> > "lld" AND NOT MINGW) OR LLVM_ENABLE_LLD)
> > ```
> > 
> > We're adding this option properly in the mingw frontend, so we shouldn't do 
> > the hacky way of passing lld-link options via the mingw frontend by passing 
> > them as /option.
> 
> I was about to add that and one more LTO related option but thought "what if 
> LLVM should link with lld-link on MinGW?" and eventually forgot about it.
> 
> 
> 
> > And the reason LINKER_IS_LLD_LINK is set seems to be this:
> > ```
> > if(CMAKE_LINKER MATCHES "lld-link" OR (WIN32 AND LLVM_USE_LINKER STREQUAL 
> > "lld") OR LLVM_ENABLE_LLD)
> > ```
> > Perhaps that should be changed into
> > ```
> > if(CMAKE_LINKER MATCHES "lld-link" OR (WIN32 AND LLVM_USE_LINKER STREQUAL 
> > "lld" AND NOT MINGW) OR LLVM_ENABLE_LLD)
> > ```
> 
> It won't work if somebody uses `LLVM_ENABLE_LLD=ON` instead of 
> `LLVM_USE_LINKER=lld` which is supposed to be equivalent.
> That raises question how `LLVM_ENABLE_LLD=ON` does even work on UNIX 
> platforms.
> 
> IMO this would be better:
> ```
> if(CMAKE_LINKER MATCHES "lld-link" OR MSVC AND (LLVM_USE_LINKER STREQUAL 
> "lld" OR LLVM_ENABLE_LLD))
> ```
> I was about to add that and one more LTO related option but thought "what if 
> LLVM should link with lld-link on MinGW?" and eventually forgot about it.

I don't think that really is a supposedly supported setup - lld-link wouldn't 
find any libs to link against etc, as the compiler driver is supposed to pass 
those as `-L` options in mingw/unix style tools.

> It won't work if somebody uses LLVM_ENABLE_LLD=ON instead of 
> LLVM_USE_LINKER=lld which is supposed to be equivalent.
> That raises question how LLVM_ENABLE_LLD=ON does even work on UNIX platforms.

Either it doesn't work and nobody actually use it that way, or the effects of 
`LINKER_IS_LLD_LINK` are mostly harmless.

> IMO this would be better:
> 
> `if(CMAKE_LINKER MATCHES "lld-link" OR MSVC AND (LLVM_USE_LINKER STREQUAL 
> "lld" OR LLVM_ENABLE_LLD))`

Yeah, that looks sensible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80425



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


Re: Bug in QualTypeNames.cpp and adding an option to prepend "::" to fully qualified names.

2020-05-25 Thread Jean-Baptiste Lespiau via cfe-commits
Hi,

should we submit this CL, adding the option to prepend classes and struct
fully qualified names with "::"?

This can then allow people to slowly switch to the new function, and I can
close my fix/close my bug in CLIF. I can do more on this CL if it is
needed, but I would like to be sure this will get submitted and I will not
waste my time, and know exactly what you want me to do.

Possible options include:
- adding the full context, with the bug, in the CL description
- adding documentation on `getFullyQualifiedName` expliciting in which
context the bug can occur
- adding a FullyQualifiedTypePrinter() that will take an AST or a
TypePolicy, and set the correct fields, so one can do
QualType.getAsString(FullyQualifiedTypePrinter(ast)) to replace the
hereabove one.
- add some tests, but I do not know where and how.

When this few lines are submitted, I can update google3 for clang, and I
can start changing some internal occurrences, and finally fix the CLIF bug.

Thanks!

On Tue, May 12, 2020 at 11:19 PM Jean-Baptiste Lespiau 
wrote:

>
>
> On Tue, May 12, 2020 at 11:11 PM David Blaikie  wrote:
>
>> On Tue, May 12, 2020 at 12:40 PM Jean-Baptiste Lespiau <
>> jblesp...@google.com> wrote:
>>
>>> Hi,
>>>
>>> thanks for your answer.
>>>
>>> Just a few remarks:
>>>
>>> 1. I imagine that we cannot know if people are using
>>> getFullyQualifiedName. In particular, people could have developed their own
>>> internal tools, thus we cannot be aware of all callers. I do not know
>>> Clang's policy, but can we delete or completely change a function without
>>> deprecating it first?
>>>
>>
>> The LLVM project offers little/no API guarantees - potentially/especially
>> for a function with no use in-tree. But, yes, as Googlers we'd be
>> encouraged not to commit an API change knowing this might cause widespread
>> internal breakage without a plan/pre-emptively fixing things.
>>
>>
>>> I was imagining that the process was to deprecate it, document the case
>>> where it can be incorrect, and that in a next release it gets
>>> deleted/replaced (or someone steps up to fix it).
>>>
>>
>> Sometimes deprecation is used - certain APIs have a lot of out of tree
>> surface area
>>
>>
>>> 2. As example of different behaviors:
>>> (a) the qual_type.getAsString() will print implementation namespace
>>> details (e.g. ::std*::__u*::variant instead of std::variant).
>>>
>>
>> Yep, that's probably not ideal for most source generating use cases.
>>
>>
>>> (b) It will also display default template arguments, e.g.
>>> template 
>>> class MyClass
>>> is printed as MyClass (I think) in getFullyQualifiedName, while
>>> getAsString() will use MyClass.
>>>
>>
>> That seems better/correct - did CLIF actually want/rely on/benefit from
>> the old behavior of only printing the template name?
>>
>
> I did check to replace all of the getFullyQualifiedName in CLIF with the
> new version: it worked like a charm. The error messages are just changed
> accordingly (so they will have longer types).
> And the generated code was also less verbose.
>
>>
>>
>>> (c) the example of the nested template argument above.
>>>
>>
>> Which seems just wrong/inconsistent/not-behaving-to-spec to me - I don't
>> imagine any caller actually wanted that behavior?
>>
>
> I agree.
>
>>
>>
>>>
>>> At the end,what matters is that getAsString() is semantically always
>>> correct, even if it can be overly verbose.
>>>
>>
>> The presence of inline namespaces is about the only bit I'd find a touch
>> questionable. (Hopefully Sam can chime in on some of that)
>>
>
> Me too, I would be curious if it is easy to remove.
>
>>
>>
>>> I tried to fix getFullyQualifiedName, but I do not understand its code.
>>>
>>> 3. When the goal we want to reach has been decided, there is also the
>>> question on how to transition from the current state to the next state, and
>>> who can help with that. To be way clearer, I won't be able to fix all of
>>> Google internal usage of this function (I am not at all working on Clang,
>>> Clif, or any tools, I just hit the bug and decided to look into it, and it
>>> happened that I found a fix). Thus, if we can do the changes using
>>> iterative steps, such as
>>> (a) add the new "::" prefix configuration,
>>> (b) Deprecate/document the fact that getFullyQualifiedName has a bug,
>>> and people should move to use qual_type.getAsString(Policy) instead, using
>>> "FullyQualifiedName" and "GlobalScopeQualifiedName". We can for example
>>> provide :
>>>
>>
>> It'd still fall to one of us Googlers to clean this all up inside Google
>> - since we build with -Werror, it's not like folks'll just get soft
>> encouragement to migrate away from the API, either the warning will be on
>> and their build will be broken (in which case we'll probably pick it up
>> when we integrate changes from upstream & have to fix it to complete that
>> integration) or no signal, and it'll break when the function is finally
>> removed.
>>
>>
>>> std::string 

[PATCH] D80472: [clangd] Add access specifier information to hover contents

2020-05-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

thanks for taking a look at this, this looks great!

mostly nits, but the one in tests is important and annoying (it might require 
you to update some existing cases)




Comment at: clang-tools-extra/clangd/Hover.cpp:680
 
+StringRef getAccessString(AccessSpecifier AS) {
+  switch (AS) {

it is annoying to have this function duplicated in each component (there are 
duplicates at least in text and json node dumpers too) :/

Feel free to provide a common implementation in 
`clang/include/clang/Basic/Specifiers.h` and migrate all other usages to it, or 
just put a FIXME in here saying we should converge those.

nit: prefer `llvm::StringRef` as return type



Comment at: clang-tools-extra/clangd/Hover.cpp:793
+  if (AccessSpecifier != AccessSpecifier::AS_none)
+Header.appendText(getAccessString(AccessSpecifier)).appendSpace();
   if (Kind != index::SymbolKind::Unknown)

I wonder if it would be more natural to put this at bottom, where we list the 
containing class/struct/union. e.g.

```
struct X { int fo^o; }
```

would result in

```
field foo
---

// In X
public: int foo
```

I find current one useful too, just listing options to see what you (and 
possibly others interested in) think.



Comment at: clang-tools-extra/clangd/Hover.h:63
+  /// Access specifier. Applies to members of class/structs or unions.
+  AccessSpecifier AccessSpecifier = AccessSpecifier::AS_none;
   /// Pretty-printed variable type.

Let's have `std::string` here, with a comment saying that `Access specifier for 
declarations inside class/struct/unions, empty for others.`



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:718
 EXPECT_EQ(H->Size, Expected.Size);
 EXPECT_EQ(H->Offset, Expected.Offset);
   }

could you also add an EXPECT_EQ for `H->AccessSpecifier` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80472



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


[PATCH] D80425: Fix LLVM/Clang builds with mingw toolchain

2020-05-25 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80425



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


[clang] 3ed8ebc - Fix return values of some matcher functions

2020-05-25 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2020-05-24T12:37:44+01:00
New Revision: 3ed8ebc2f6b8172bed48cc5986d3b7af4cfca1bc

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

LOG: Fix return values of some matcher functions

The old return values mean

* implicit conversion
* not being able to write sizeOfExpr().bind() for example

Added: 


Modified: 
clang/include/clang/ASTMatchers/ASTMatchers.h

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 460962d9e73b..a750747c9aa3 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2662,7 +2662,7 @@ AST_MATCHER_P(UnaryExprOrTypeTraitExpr, ofKind, 
UnaryExprOrTypeTrait, Kind) {
 
 /// Same as unaryExprOrTypeTraitExpr, but only matching
 /// alignof.
-inline internal::Matcher alignOfExpr(
+inline internal::BindableMatcher alignOfExpr(
 const internal::Matcher ) {
   return stmt(unaryExprOrTypeTraitExpr(
   allOf(anyOf(ofKind(UETT_AlignOf), ofKind(UETT_PreferredAlignOf)),
@@ -2671,7 +2671,7 @@ inline internal::Matcher alignOfExpr(
 
 /// Same as unaryExprOrTypeTraitExpr, but only matching
 /// sizeof.
-inline internal::Matcher sizeOfExpr(
+inline internal::BindableMatcher sizeOfExpr(
 const internal::Matcher ) {
   return stmt(unaryExprOrTypeTraitExpr(
   allOf(ofKind(UETT_SizeOf), InnerMatcher)));



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


[PATCH] D69585: Add option to instantiate templates already in the PCH

2020-05-25 Thread Luboš Luňák via Phabricator via cfe-commits
llunak updated this revision to Diff 265918.
llunak edited the summary of this revision.
llunak added a comment.

Enabled the option by default for clang-cl to match MSVC.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69585

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/PCH/codegen.cpp
  clang/test/PCH/crash-12631281.cpp
  clang/test/PCH/cxx-alias-decl.cpp
  clang/test/PCH/cxx-dependent-sized-ext-vector.cpp
  clang/test/PCH/cxx-explicit-specifier.cpp
  clang/test/PCH/cxx-exprs.cpp
  clang/test/PCH/cxx-friends.cpp
  clang/test/PCH/cxx-member-init.cpp
  clang/test/PCH/cxx-ms-function-specialization-class-scope.cpp
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/PCH/cxx-templates.cpp
  clang/test/PCH/cxx-variadic-templates-with-default-params.cpp
  clang/test/PCH/cxx-variadic-templates.cpp
  clang/test/PCH/cxx0x-default-delete.cpp
  clang/test/PCH/cxx11-constexpr.cpp
  clang/test/PCH/cxx11-enum-template.cpp
  clang/test/PCH/cxx11-exception-spec.cpp
  clang/test/PCH/cxx11-inheriting-ctors.cpp
  clang/test/PCH/cxx11-user-defined-literals.cpp
  clang/test/PCH/cxx1y-decltype-auto.cpp
  clang/test/PCH/cxx1y-deduced-return-type.cpp
  clang/test/PCH/cxx1y-default-initializer.cpp
  clang/test/PCH/cxx1y-init-captures.cpp
  clang/test/PCH/cxx1y-variable-templates.cpp
  clang/test/PCH/cxx1z-aligned-alloc.cpp
  clang/test/PCH/cxx1z-decomposition.cpp
  clang/test/PCH/cxx1z-using-declaration.cpp
  clang/test/PCH/cxx2a-bitfield-init.cpp
  clang/test/PCH/cxx2a-concept-specialization-expr.cpp
  clang/test/PCH/cxx2a-constraints.cpp
  clang/test/PCH/cxx2a-defaulted-comparison.cpp
  clang/test/PCH/cxx2a-requires-expr.cpp
  clang/test/PCH/cxx2a-template-lambdas.cpp
  clang/test/PCH/delayed-pch-instantiate.cpp
  clang/test/PCH/friend-template.cpp
  clang/test/PCH/implicitly-deleted.cpp
  clang/test/PCH/late-parsed-instantiations.cpp
  clang/test/PCH/local_static.cpp
  clang/test/PCH/macro-undef.cpp
  clang/test/PCH/make-integer-seq.cpp
  clang/test/PCH/ms-if-exists.cpp
  clang/test/PCH/pch-instantiate-templates-forward-decl.cpp
  clang/test/PCH/pch-instantiate-templates.cpp
  clang/test/PCH/pr18806.cpp
  clang/test/PCH/pragma-diag-section.cpp
  clang/test/PCH/rdar10830559.cpp
  clang/test/PCH/specialization-after-instantiation.cpp
  clang/test/PCH/type_pack_element.cpp

Index: clang/test/PCH/type_pack_element.cpp
===
--- clang/test/PCH/type_pack_element.cpp
+++ clang/test/PCH/type_pack_element.cpp
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -std=c++14 -x c++-header %s -emit-pch -o %t.pch
 // RUN: %clang_cc1 -std=c++14 -x c++ /dev/null -include-pch %t.pch
 
+// RUN: %clang_cc1 -std=c++14 -x c++-header %s -emit-pch -fpch-instantiate-templates -o %t.pch
+// RUN: %clang_cc1 -std=c++14 -x c++ /dev/null -include-pch %t.pch
+
 template 
 struct X { };
 
Index: clang/test/PCH/specialization-after-instantiation.cpp
===
--- /dev/null
+++ clang/test/PCH/specialization-after-instantiation.cpp
@@ -0,0 +1,32 @@
+// Test this without pch.
+// RUN: %clang_cc1 -fsyntax-only -verify -DBODY %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify -DBODY %s
+
+// RUN: %clang_cc1 -emit-pch -fpch-instantiate-templates -o %t %s
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify -DBODY %s
+
+#ifndef HEADER_H
+#define HEADER_H
+
+template 
+struct A {
+  int foo() const;
+};
+
+int bar(A *a) {
+  return a->foo();
+}
+
+#endif // HEADER_H
+
+#ifdef BODY
+
+template <>
+int A::foo() const { // expected-error {{explicit specialization of 'foo' after instantiation}}  // expected-note@20 {{implicit instantiation first required here}}
+  return 10;
+}
+
+#endif // BODY
Index: clang/test/PCH/rdar10830559.cpp
===
--- clang/test/PCH/rdar10830559.cpp
+++ clang/test/PCH/rdar10830559.cpp
@@ -6,6 +6,9 @@
 // RUN: %clang_cc1 -emit-pch -o %t %s
 // RUN: %clang_cc1 -include-pch %t -emit-llvm-only %t.empty.cpp 
 
+// RUN: %clang_cc1 -emit-pch -fpch-instantiate-templates -o %t %s
+// RUN: %clang_cc1 -include-pch %t -emit-llvm-only %t.empty.cpp
+
 // rdar://10830559
 
 //#pragma ms_struct on
Index: clang/test/PCH/pragma-diag-section.cpp
===
--- clang/test/PCH/pragma-diag-section.cpp
+++ clang/test/PCH/pragma-diag-section.cpp
@@ -5,6 +5,9 @@
 // RUN: %clang_cc1 %s -emit-pch -o %t
 // RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only -Wuninitialized
 
+// RUN: %clang_cc1 %s -emit-pch -fpch-instantiate-templates -o %t
+// RUN: 

[PATCH] D69585: Add option to instantiate templates already in the PCH

2020-05-25 Thread Luboš Luňák via Phabricator via cfe-commits
llunak marked an inline comment as done.
llunak added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5610
+  if (Args.hasFlag(options::OPT_fpch_instantiate_templates,
+   options::OPT_fno_pch_instantiate_templates, false))
+CmdArgs.push_back("-fpch-instantiate-templates");

rnk wrote:
> llunak wrote:
> > rnk wrote:
> > > Does MSVC default to this behavior? Should this default to true with 
> > > clang-cl /Yu / /Yc? This can be future work and does not need to be part 
> > > of this patch.
> > Since MSVC is noticeably faster for an equivalent PCH compile than current 
> > Clang, presumably it instantiates templates already in the PCH. But that 
> > doesn't really matter for this patch, if it were ok to enable this by 
> > default for clang-cl, than it would be ok also for clang itself. That 
> > cannot be done now though, https://reviews.llvm.org/D69585#1946765 points 
> > out a corner case where this change makes a valid compilation error out, 
> > and that's the reason for having this behind a flag. I expect Clang could 
> > possibly be adjusted to bail out and delay template instantiantion in such 
> > a case until it can be performed successfully, but given the response rate 
> > to my PCH patches I first wanted to get the feature in somehow, and I can 
> > try to make the flag default/irrelevant later.
> > 
> Right, I guess what I mean is, for that example where instantiation at the 
> end of the PCH creates an error, does MSVC emit an error? I just checked, and 
> it looks like the answer is yes, so it seems like we could make this the 
> default behavior for `clang-cl /Yc` without much further discussion.
That's a good point. Yes, since MSVC creates PCHs by basically compiling an 
empty .cpp, it apparently does instantiate templates as a side-effect of that, 
and https://reviews.llvm.org/D69585#1946765 indeed doesn't work with MSVC. So 
no harm in enabling the option for clang-cl.

I'll update the patch.



Repository:
  rC Clang

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

https://reviews.llvm.org/D69585



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


[clang] 04ed532 - Fix skip-invisible with overloaded method calls

2020-05-25 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2020-05-24T12:36:16+01:00
New Revision: 04ed532ef0ce76d53ca456cbc581756bb01d30e7

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

LOG: Fix skip-invisible with overloaded method calls

Added: 


Modified: 
clang/lib/AST/Expr.cpp
clang/unittests/AST/ASTTraverserTest.cpp

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index f173c2408866..0184140ab07e 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -2931,8 +2931,10 @@ Expr *Expr::IgnoreUnlessSpelledInSource() {
 continue;
   }
   if (auto *PE = dyn_cast(ExprNode)) {
-E = PE;
-continue;
+if (PE->getSourceRange() == C->getSourceRange()) {
+  E = PE;
+  continue;
+}
   }
   ExprNode = ExprNode->IgnoreParenImpCasts();
   if (ExprNode->getSourceRange() == SR)

diff  --git a/clang/unittests/AST/ASTTraverserTest.cpp 
b/clang/unittests/AST/ASTTraverserTest.cpp
index f56a49bf8e51..affbbe76f0d2 100644
--- a/clang/unittests/AST/ASTTraverserTest.cpp
+++ b/clang/unittests/AST/ASTTraverserTest.cpp
@@ -265,6 +265,9 @@ TEST(Traverse, IgnoreUnlessSpelledInSourceVars) {
 struct String
 {
 String(const char*, int = -1) {}
+
+int overloaded() const;
+int& overloaded();
 };
 
 void stringConstruct()
@@ -273,6 +276,12 @@ void stringConstruct()
 s = "bar";
 }
 
+void overloadCall()
+{
+   String s = "foo";
+   (s).overloaded();
+}
+
 struct C1 {};
 struct C2 { operator C1(); };
 
@@ -331,6 +340,46 @@ FunctionDecl 'stringConstruct'
 )cpp");
   }
 
+  {
+auto FN =
+ast_matchers::match(functionDecl(hasName("overloadCall")).bind("fn"),
+AST->getASTContext());
+EXPECT_EQ(FN.size(), 1u);
+
+EXPECT_EQ(dumpASTString(TK_AsIs, FN[0].getNodeAs("fn")),
+  R"cpp(
+FunctionDecl 'overloadCall'
+`-CompoundStmt
+  |-DeclStmt
+  | `-VarDecl 's'
+  |   `-ExprWithCleanups
+  | `-CXXConstructExpr
+  |   `-MaterializeTemporaryExpr
+  | `-ImplicitCastExpr
+  |   `-CXXConstructExpr
+  | |-ImplicitCastExpr
+  | | `-StringLiteral
+  | `-CXXDefaultArgExpr
+  `-CXXMemberCallExpr
+`-MemberExpr
+  `-ParenExpr
+`-DeclRefExpr 's'
+)cpp");
+
+EXPECT_EQ(dumpASTString(TK_IgnoreUnlessSpelledInSource,
+FN[0].getNodeAs("fn")),
+  R"cpp(
+FunctionDecl 'overloadCall'
+`-CompoundStmt
+  |-DeclStmt
+  | `-VarDecl 's'
+  |   `-StringLiteral
+  `-CXXMemberCallExpr
+`-MemberExpr
+  `-DeclRefExpr 's'
+)cpp");
+  }
+
   {
 auto FN = ast_matchers::match(
 functionDecl(hasName("conversionOperator"),



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


[clang-tools-extra] 5e9392d - Add explicit traversal mode to matchers for implicit constructors

2020-05-25 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2020-05-24T12:36:15+01:00
New Revision: 5e9392deaf5bfa43846334e9b07a126ae3410a38

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

LOG: Add explicit traversal mode to matchers for implicit constructors

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp
clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
index 1c47f17d8a64..96d93a1d0413 100644
--- a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
@@ -100,10 +100,11 @@ void StringConstructorCheck::registerMatchers(MatchFinder 
*Finder) {
   // Check the literal string constructor with char pointer.
   // [i.e. string (const char* s);]
   Finder->addMatcher(
+traverse(TK_AsIs,
   cxxConstructExpr(hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
hasArgument(0, expr().bind("from-ptr")),
hasArgument(1, unless(hasType(isInteger()
-  .bind("constructor"),
+  .bind("constructor")),
   this);
 }
 

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp
index 815062618a97..b533db760d5e 100644
--- 
a/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/bugprone/StringLiteralWithEmbeddedNulCheck.cpp
@@ -49,8 +49,8 @@ void 
StringLiteralWithEmbeddedNulCheck::registerMatchers(MatchFinder *Finder) {
 
   // Detect passing a suspicious string literal to a string constructor.
   // example: std::string str = "abc\0def";
-  Finder->addMatcher(
-  cxxConstructExpr(StringConstructorExpr, hasArgument(0, StrLitWithNul)),
+  Finder->addMatcher(traverse(TK_AsIs,
+  cxxConstructExpr(StringConstructorExpr, hasArgument(0, StrLitWithNul))),
   this);
 
   // Detect passing a suspicious string literal through an overloaded operator.

diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
index 78bf744eba8d..e5825bc4f0e3 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -96,8 +96,9 @@ void RedundantStringInitCheck::registerMatchers(MatchFinder 
*Finder) {
 
   const auto StringType = hasType(hasUnqualifiedDesugaredType(
   recordType(hasDeclaration(cxxRecordDecl(hasStringTypeName);
-  const auto EmptyStringInit = expr(ignoringImplicit(
-  anyOf(EmptyStringCtorExpr, EmptyStringCtorExprWithTemporaries)));
+  const auto EmptyStringInit =
+  traverse(ast_type_traits::TK_AsIs, expr(ignoringImplicit(
+  anyOf(EmptyStringCtorExpr, EmptyStringCtorExprWithTemporaries;
 
   // Match a variable declaration with an empty string literal as initializer.
   // Examples:



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


[PATCH] D80486: [clang-format][PR46043] Parse git config w/ implicit values

2020-05-25 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay 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/D80486/new/

https://reviews.llvm.org/D80486



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


[clang] 72210ce - Fix Wdocumentation warnings after argument renaming. NFC.

2020-05-25 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-05-24T11:18:20+01:00
New Revision: 72210ce7f57192652414ebbdf9f643f86532d700

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

LOG: Fix Wdocumentation warnings after argument renaming. NFC.

Added: 


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

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index 7fae3a62211d..a7c62a7e8046 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -445,7 +445,7 @@ class MallocChecker
 
   /// Perform a zero-allocation check.
   ///
-  /// \param [in] E The expression that allocates memory.
+  /// \param [in] Call The expression that allocates memory.
   /// \param [in] IndexOfSizeArg Index of the argument that specifies the size
   ///   of the memory that needs to be allocated. E.g. for malloc, this would 
be
   ///   0.
@@ -469,7 +469,7 @@ class MallocChecker
   ///   - first: name of the resource (e.g. 'malloc')
   ///   - (OPTIONAL) second: size of the allocated region
   ///
-  /// \param [in] CE The expression that allocates memory.
+  /// \param [in] Call The expression that allocates memory.
   /// \param [in] Att The ownership_returns attribute.
   /// \param [in] State The \c ProgramState right before allocation.
   /// \returns The ProgramState right after allocation.
@@ -480,7 +480,7 @@ class MallocChecker
 
   /// Models memory allocation.
   ///
-  /// \param [in] CE The expression that allocates memory.
+  /// \param [in] Call The expression that allocates memory.
   /// \param [in] SizeEx Size of the memory that needs to be allocated.
   /// \param [in] Init The value the allocated memory needs to be initialized.
   /// with. For example, \c calloc initializes the allocated memory to 0,
@@ -495,7 +495,7 @@ class MallocChecker
 
   /// Models memory allocation.
   ///
-  /// \param [in] CE The expression that allocates memory.
+  /// \param [in] Call The expression that allocates memory.
   /// \param [in] Size Size of the memory that needs to be allocated.
   /// \param [in] Init The value the allocated memory needs to be initialized.
   /// with. For example, \c calloc initializes the allocated memory to 0,
@@ -532,7 +532,7 @@ class MallocChecker
   ///   - first: name of the resource (e.g. 'malloc')
   ///   - second: index of the parameter the attribute applies to
   ///
-  /// \param [in] CE The expression that frees memory.
+  /// \param [in] Call The expression that frees memory.
   /// \param [in] Att The ownership_takes or ownership_holds attribute.
   /// \param [in] State The \c ProgramState right before allocation.
   /// \returns The ProgramState right after deallocation.
@@ -543,7 +543,7 @@ class MallocChecker
 
   /// Models memory deallocation.
   ///
-  /// \param [in] CE The expression that frees memory.
+  /// \param [in] Call The expression that frees memory.
   /// \param [in] State The \c ProgramState right before allocation.
   /// \param [in] Num Index of the argument that needs to be freed. This is
   ///   normally 0, but for custom free functions it may be 
diff erent.
@@ -570,7 +570,7 @@ class MallocChecker
   /// Models memory deallocation.
   ///
   /// \param [in] ArgExpr The variable who's pointee needs to be freed.
-  /// \param [in] ParentExpr The expression that frees the memory.
+  /// \param [in] Call The expression that frees the memory.
   /// \param [in] State The \c ProgramState right before allocation.
   ///   normally 0, but for custom free functions it may be 
diff erent.
   /// \param [in] Hold Whether the parameter at \p Index has the 
ownership_holds
@@ -599,7 +599,7 @@ class MallocChecker
   //
   /// Models memory reallocation.
   ///
-  /// \param [in] CE The expression that reallocated memory
+  /// \param [in] Call The expression that reallocated memory
   /// \param [in] ShouldFreeOnFail Whether if reallocation fails, the supplied
   ///   memory should be freed.
   /// \param [in] State The \c ProgramState right before reallocation.
@@ -623,7 +623,7 @@ class MallocChecker
 
   /// Models zero initialized array allocation.
   ///
-  /// \param [in] CE The expression that reallocated memory
+  /// \param [in] Call The expression that reallocated memory
   /// \param [in] State The \c ProgramState right before reallocation.
   /// \returns The ProgramState right after allocation.
   LLVM_NODISCARD



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


[PATCH] D80490: Check for rule of five and zero.

2020-05-25 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar created this revision.
vrnithinkumar added reviewers: aaron.ballman, alexfh, jbcoe, dblaikie, rsmith.
Herald added subscribers: cfe-commits, kbarton, mgorny, nemanjai.
Herald added a project: clang.

New check to check if a class defines all special members of none of them. This 
also known as rule of five and zero.
Specified in CppCoreGuidelines: 
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c21-if-you-define-or-delete-any-default-operation-define-or-delete-them-all.
In summary the check will

- Checks class defines all special members of none of them.
- It also see if the base class deletes the special members or not.
- Has two modes with the flag strict-check.
- Strict mode will check all or nothing strictly.

For some combination, compiler explicitly delete the special members or  does 
not declare implicitly. In that case don'nt have to define all the special 
members. 
For example, in case of defining all members except move constructor and move 
assignment compiler will not implicitly declare the move constructor and move 
assignment.
For non strict mode we will consider these combinations as safe.

I found one review https://reviews.llvm.org/D16376 already related to this. 
I modified my changes based on this. But I could not find out why this got 
abandoned.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80490

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/RuleOfFiveAndZeroCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/RuleOfFiveAndZeroCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-rule-of-five-and-zero.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-rule-of-five-and-zero-strict.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-rule-of-five-and-zero.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-rule-of-five-and-zero.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-rule-of-five-and-zero.cpp
@@ -0,0 +1,122 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-rule-of-five-and-zero %t
+
+class DefinesNothing {
+};
+
+class DefinesEverything {
+  DefinesEverything(const DefinesEverything &);
+  DefinesEverything =(const DefinesEverything &);
+  DefinesEverything(DefinesEverything &&);
+  DefinesEverything =(DefinesEverything &&);
+  ~DefinesEverything();
+};
+
+class DeletesEverything {
+  DeletesEverything(const DeletesEverything &);
+  DeletesEverything =(const DeletesEverything &);
+  DeletesEverything(DeletesEverything &&);
+  DeletesEverything =(DeletesEverything &&);
+  ~DeletesEverything();
+};
+
+// Safe cases
+class DefinesAllExceptMoves {
+  ~DefinesAllExceptMoves();
+  DefinesAllExceptMoves(DefinesAllExceptMoves &);
+  DefinesAllExceptMoves =(DefinesAllExceptMoves &);
+};
+
+class DefinesAllExceptMoveConstructor {
+  ~DefinesAllExceptMoveConstructor();
+  DefinesAllExceptMoveConstructor(DefinesAllExceptMoveConstructor &);
+  DefinesAllExceptMoveConstructor =(DefinesAllExceptMoveConstructor &);
+  DefinesAllExceptMoveConstructor =(DefinesAllExceptMoveConstructor &&);
+};
+
+class DefinesAllExceptMoveAssignment {
+  ~DefinesAllExceptMoveAssignment();
+  DefinesAllExceptMoveAssignment(DefinesAllExceptMoveAssignment &);
+  DefinesAllExceptMoveAssignment =(DefinesAllExceptMoveAssignment &);
+  DefinesAllExceptMoveAssignment(DefinesAllExceptMoveAssignment &&);
+};
+
+class DefinesDestructorAndMoveConstructor {
+  ~DefinesDestructorAndMoveConstructor();
+  DefinesDestructorAndMoveConstructor(DefinesDestructorAndMoveConstructor &&);
+};
+
+class DefinesDestructorAndMoveAssignment {
+  ~DefinesDestructorAndMoveAssignment();
+  DefinesDestructorAndMoveAssignment =(DefinesDestructorAndMoveAssignment &&);
+};
+
+// CHECK-MESSAGES: :[[@LINE+1]]:7: warning: class 'DefinesOnlyDestructor' defines a destructor but does not define all other 5, define all other 5 or delete all other special member functions [cppcoreguidelines-rule-of-five-and-zero]
+class DefinesOnlyDestructor {
+  ~DefinesOnlyDestructor();
+};
+
+// CHECK-MESSAGES: :[[@LINE+1]]:7: warning: class 'DefinesOnlyCopyConstructor' defines a copy constructor but does not define all other 5, define all other 5 or delete all other special member functions [cppcoreguidelines-rule-of-five-and-zero]
+class DefinesOnlyCopyConstructor {
+  DefinesOnlyCopyConstructor(const DefinesOnlyCopyConstructor &);
+};
+
+// CHECK-MESSAGES: :[[@LINE+1]]:7: warning: class 'DefinesOnlyMoveConstructor' defines a move constructor but does not define all other 5, define all other 5 or delete all other special member functions [cppcoreguidelines-rule-of-five-and-zero]

[PATCH] D80488: Teach `-fsanitize=fuzzer` to respect `-static` and `-static-libstdc++` when adding C++ standard libraries.

2020-05-25 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc created this revision.
Herald added subscribers: cfe-commits, mcrosier.
Herald added a project: clang.

No idea if this is 'correct' or the right way to fix this, so just
sending this mostly as an FYI. Someone who works more closely on the
sanitizers might need to take it over and figure out how this should be
working and add relevant test cases, etc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80488

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


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -747,8 +747,15 @@
   !Args.hasArg(options::OPT_shared)) {
 
 addSanitizerRuntime(TC, Args, CmdArgs, "fuzzer", false, true);
-if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx))
+if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx)) {
+  bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
+ !Args.hasArg(options::OPT_static);
+  if (OnlyLibstdcxxStatic)
+CmdArgs.push_back("-Bstatic");
   TC.AddCXXStdlibLibArgs(Args, CmdArgs);
+  if (OnlyLibstdcxxStatic)
+CmdArgs.push_back("-Bdynamic");
+}
   }
 
   for (auto RT : SharedRuntimes)


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -747,8 +747,15 @@
   !Args.hasArg(options::OPT_shared)) {
 
 addSanitizerRuntime(TC, Args, CmdArgs, "fuzzer", false, true);
-if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx))
+if (!Args.hasArg(clang::driver::options::OPT_nostdlibxx)) {
+  bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
+ !Args.hasArg(options::OPT_static);
+  if (OnlyLibstdcxxStatic)
+CmdArgs.push_back("-Bstatic");
   TC.AddCXXStdlibLibArgs(Args, CmdArgs);
+  if (OnlyLibstdcxxStatic)
+CmdArgs.push_back("-Bdynamic");
+}
   }
 
   for (auto RT : SharedRuntimes)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] b752a27 - [clangd] Log use of heuristic go-to-def. NFC

2020-05-25 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-05-25T10:19:34+02:00
New Revision: b752a2743ab0d24d8da5d97c07fbdb996df78b1f

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

LOG: [clangd] Log use of heuristic go-to-def. NFC

Generally:
 - found results using this method -> log
 - no results using this method -> vlog
 - method wasn't applied because ineligible -> no log

Added: 


Modified: 
clang-tools-extra/clangd/XRefs.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 1d82763b6a3c..1fc0e0348d09 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -438,8 +438,11 @@ locateSymbolTextually(const SpelledWord , ParsedAST 
,
 ScoredResults.push_back({Score, std::move(Located)});
   });
 
-  if (TooMany)
+  if (TooMany) {
+vlog("Heuristic index lookup for {0} returned too many candidates, 
ignored",
+ Word.Text);
 return {};
+  }
 
   llvm::sort(ScoredResults,
  [](const ScoredLocatedSymbol , const ScoredLocatedSymbol ) {
@@ -448,6 +451,10 @@ locateSymbolTextually(const SpelledWord , ParsedAST 
,
   std::vector Results;
   for (auto  : std::move(ScoredResults))
 Results.push_back(std::move(Res.second));
+  if (Results.empty())
+vlog("No heuristic index definition for {0}", Word.Text);
+  else
+log("Found definition heuristically in index for {0}", Word.Text);
   return Results;
 }
 
@@ -570,13 +577,22 @@ std::vector locateSymbolAt(ParsedAST , 
Position Pos,
 // Is the same word nearby a real identifier that might refer to something?
 if (const syntax::Token *NearbyIdent =
 findNearbyIdentifier(*Word, AST.getTokens())) {
-  if (auto Macro = locateMacroReferent(*NearbyIdent, AST, *MainFilePath))
+  if (auto Macro = locateMacroReferent(*NearbyIdent, AST, *MainFilePath)) {
+log("Found macro definition heuristically using nearby identifier {0}",
+Word->Text);
 return {*std::move(Macro)};
+  }
   ASTResults =
   locateASTReferent(NearbyIdent->location(), NearbyIdent, AST,
 *MainFilePath, Index, /*NodeKind=*/nullptr);
-  if (!ASTResults.empty())
+  if (!ASTResults.empty()) {
+log("Found definition heuristically using nearby identifier {0}",
+NearbyIdent->text(SM));
 return ASTResults;
+  } else {
+vlog("No definition found using nearby identifier {0} at {1}",
+ Word->Text, Word->Location.printToString(SM));
+  }
 }
 // No nearby word, or it didn't refer to anything either. Try the index.
 auto TextualResults =



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


[clang-tools-extra] 72c5ea1 - [clangd] Enable cross-file-rename by default.

2020-05-25 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-05-25T10:46:57+02:00
New Revision: 72c5ea1d73bb89af6f82c14ddb0b7f4c2510bab7

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

LOG: [clangd] Enable cross-file-rename by default.

Summary:
The cross-file rename feature is stable enough to enable it (has been
rolled out internally for a few weeks).

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/tool/ClangdMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp 
b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index 031f57f954cb..cab6c97cf121 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -274,11 +274,8 @@ list TweakList{
 opt CrossFileRename{
 "cross-file-rename",
 cat(Features),
-desc("Enable cross-file rename feature. Note that this feature is "
- "experimental and may lead to broken code or incomplete rename "
- "results"),
-init(false),
-Hidden,
+desc("Enable cross-file rename feature."),
+init(true),
 };
 
 opt RecoveryAST{



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


[PATCH] D80507: [clangd] Enable cross-file-rename by default.

2020-05-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

I suspect we're going to get some complaints from people whose index is 
perpetually behind and missing files, but this is the tradeoff of the design, 
we have to accept that or refine (e.g. with a textual index).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80507



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


[PATCH] D79961: [PGO] Fix computation of fuction Hash

2020-05-25 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

Up?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79961



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


[PATCH] D80507: [clangd] Enable cross-file-rename by default.

2020-05-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

The cross-file rename feature is stable enough to enable it (has been
rolled out internally for a few weeks).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80507

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -274,11 +274,8 @@
 opt CrossFileRename{
 "cross-file-rename",
 cat(Features),
-desc("Enable cross-file rename feature. Note that this feature is "
- "experimental and may lead to broken code or incomplete rename "
- "results"),
-init(false),
-Hidden,
+desc("Enable cross-file rename feature."),
+init(true),
 };
 
 opt RecoveryAST{


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -274,11 +274,8 @@
 opt CrossFileRename{
 "cross-file-rename",
 cat(Features),
-desc("Enable cross-file rename feature. Note that this feature is "
- "experimental and may lead to broken code or incomplete rename "
- "results"),
-init(false),
-Hidden,
+desc("Enable cross-file rename feature."),
+init(true),
 };
 
 opt RecoveryAST{
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80079: [clang-format] [NFC] isCpp() is inconsistently used to mean both C++ and Objective C, add language specific isXXX() functions

2020-05-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D80079#2049459 , @MyDeveloperDay 
wrote:

> I feel like there might something of a concencus forming.. If I take the time 
> to redo following the suggestions @sammccall do you think you could live with 
> it?


Yeah, LGTM. The alignment of the existing name with clang wasn't as close as I 
thought anyway. Sorry about adding friction here.

I feel like `isCppOrObjC` doesn't cover the "essence" of the thing being 
tested. But it's hard to come up with a great name because it's not clear 
whether this essence is about C or about C++ (we don't distinguish, and the 
answer varies depending on callsite).
Actually `isCFamily` might be a better name here - it's short, decides this is 
about C but clearly includes the others too. But I'm bikeshedding now, I can 
live with the current or any other option.

Regarding helpers vs no helpers for the trivial cases: I'm personally not a fan 
but this is just a question of taste and at this point your opinion is more 
important I think.


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

https://reviews.llvm.org/D80079



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


[PATCH] D69764: [clang-format] Add East/West Const fixer capability

2020-05-25 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:1378
 
+**ConstStyle** (``ConstAlignmentStyle``)
+  Different ways to arrange const.

MyDeveloperDay wrote:
> aaron.ballman wrote:
> > MyDeveloperDay wrote:
> > > klimek wrote:
> > > > Personally, I'm somewhat against having 3 different aliases for the 
> > > > options. I'd chose one, even though it doesn't make everybody happy, 
> > > > and move on. I'm fine with East/West as long as the documentation makes 
> > > > it clear what it is.
> > > If I have to drop the other options, I think I'd want to go with 
> > > East/West const as I feel it has more momentum, just letting people know 
> > > before I change the code back (to my original patch ;-) )
> > > 
> > > https://www.youtube.com/watch?v=gRmI_gsNqcI
> > > 
> > > {F10954065}
> > > 
> > @klimek I requested that we do not go with East/West the options and I'm 
> > still pretty insistent on it. East/West is a kitschy way to phrase it that 
> > I think is somewhat US-centric (where we make a pretty big distinction 
> > between the east and west coasts). I do not want to have to mentally map 
> > left/right to the less-clear east/west in the config file. Would you be 
> > fine if we only had Left/Right instead of East/West? I would be fine with 
> > that option, but figured enough people like the cute East/West designation 
> > that we might as well support it.
> Just for a reference, I'm not from the US and I think east/west still 
> translates pretty well. I was happy to support the others. 
I'd be fine with only having left/right; my personal feeling is also that 
west-const / east-const has kinda become a term of art, though, so I really 
don't know which one is "right" :)

Generally, I think this is one of the cases where, given good docs, we're 
quickly spending more engineering hours discussing the right solution than 
it'll cost aggregated over all future users, under the assumption that people 
do not write new configs very often, and the few who will, will quickly 
remember.



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

https://reviews.llvm.org/D69764



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


[PATCH] D79426: [clangd] Change PreambleOnlyAction with content truncation

2020-05-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/Preamble.cpp:125
   auto ContentsBuffer = llvm::MemoryBuffer::getMemBuffer(Contents);
+  auto Bounds =
+  ComputePreambleBounds(*CI->getLangOpts(), ContentsBuffer.get(), 0);

Maybe add a comment here:
```
// This means we're scanning (though not preprocessing) the preamble section 
twice.
// However, it's important to precisely follow the preamble bounds used 
elsewhere.
```

This guards somewhat against someone sending the reverse patch. Chesterton's 
fence etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79426



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


  1   2   3   >