[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros

2022-11-19 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92bccf5d3d21: [clang-format] Dont use PPIndentWidth 
inside multi-line macros (authored by goldstein.w.n, committed by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137181

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/TokenAnnotator.h
  clang/lib/Format/UnwrappedLineFormatter.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
@@ -5059,6 +5059,213 @@
"  int y = 0;\n"
"}",
style);
+
+  style.IndentPPDirectives = FormatStyle::PPDIS_None;
+  verifyFormat("#ifdef foo\n"
+   "#define bar() \\\n"
+   "if (A) {  \\\n"
+   "B();  \\\n"
+   "} \\\n"
+   "C();\n"
+   "#endif",
+   style);
+  verifyFormat("if (emacs) {\n"
+   "#ifdef is\n"
+   "#define lit   \\\n"
+   "if (af) { \\\n"
+   "return duh(); \\\n"
+   "}\n"
+   "#endif\n"
+   "}",
+   style);
+  verifyFormat("#if abc\n"
+   "#ifdef foo\n"
+   "#define bar()\\\n"
+   "if (A) { \\\n"
+   "if (B) { \\\n"
+   "C(); \\\n"
+   "}\\\n"
+   "}\\\n"
+   "D();\n"
+   "#endif\n"
+   "#endif",
+   style);
+  verifyFormat("#ifndef foo\n"
+   "#define foo\n"
+   "if (emacs) {\n"
+   "#ifdef is\n"
+   "#define lit   \\\n"
+   "if (af) { \\\n"
+   "return duh(); \\\n"
+   "}\n"
+   "#endif\n"
+   "}\n"
+   "#endif",
+   style);
+  verifyFormat("#if 1\n"
+   "#define X  \\\n"
+   "{  \\\n"
+   "x; \\\n"
+   "x; \\\n"
+   "}\n"
+   "#endif",
+   style);
+  verifyFormat("#define X  \\\n"
+   "{  \\\n"
+   "x; \\\n"
+   "x; \\\n"
+   "}",
+   style);
+
+  style.PPIndentWidth = 2;
+  verifyFormat("#ifdef foo\n"
+   "#define bar() \\\n"
+   "if (A) {  \\\n"
+   "B();  \\\n"
+   "} \\\n"
+   "C();\n"
+   "#endif",
+   style);
+  style.IndentWidth = 8;
+  verifyFormat("#ifdef foo\n"
+   "#define bar()\\\n"
+   "if (A) { \\\n"
+   "B(); \\\n"
+   "}\\\n"
+   "C();\n"
+   "#endif",
+   style);
+
+  style.IndentWidth = 1;
+  style.PPIndentWidth = 4;
+  verifyFormat("#if 1\n"
+   "#define X \\\n"
+   " {\\\n"
+   "  x;  \\\n"
+   "  x;  \\\n"
+   " }\n"
+   "#endif",
+   style);
+  verifyFormat("#define X \\\n"
+   " {\\\n"
+   "  x;  \\\n"
+   "  x;  \\\n"
+   " }",
+   style);
+
+  style.IndentWidth = 4;
+  style.PPIndentWidth = 1;
+  style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  verifyFormat("#ifdef foo\n"
+   "# define bar() \\\n"
+   " if (A) {  \\\n"
+   " B();  \\\n"
+   " } \\\n"
+   " C();\n"
+   "#endif",
+   style);
+  verifyFormat("#if abc\n"
+   "# ifdef foo\n"
+   "#  define bar()\\\n"
+   "  if (A) { \\\n"
+   "  if (B) { \\\n"
+   "  C(); \\\n"
+   "  }\\\n"
+   "  }\\\n"
+   "  D();\n"
+   "# endif\n"
+   "#endif",
+   style);
+  verifyFormat("#ifndef foo\n"
+   "#define foo\n"
+   "if (emacs) {\n"
+   "#ifdef is\n"
+   "# define lit   \\\n"
+   " if (af) { \\\n"
+   " return duh(); \\\n"
+   " }\n"
+   "#endif\n"
+  

[clang] 92bccf5 - [clang-format] Don't use PPIndentWidth inside multi-line macros

2022-11-19 Thread Owen Pan via cfe-commits

Author: Noah Goldstein
Date: 2022-11-19T23:53:48-08:00
New Revision: 92bccf5d3d2122d57f12dc07d4781e90edefd7ef

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

LOG: [clang-format] Don't use PPIndentWidth inside multi-line macros

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/TokenAnnotator.h
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Format/UnwrappedLineParser.h
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 6c4d908f96c8d..e7280df4c78e4 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -5095,8 +5095,9 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine 
,
 }
 
 void TokenAnnotator::printDebugInfo(const AnnotatedLine ) const {
-  llvm::errs() << "AnnotatedTokens(L=" << Line.Level << ", T=" << Line.Type
-   << ", C=" << Line.IsContinuation << "):\n";
+  llvm::errs() << "AnnotatedTokens(L=" << Line.Level << ", P=" << Line.PPLevel
+   << ", T=" << Line.Type << ", C=" << Line.IsContinuation
+   << "):\n";
   const FormatToken *Tok = Line.First;
   while (Tok) {
 llvm::errs() << " M=" << Tok->MustBreakBefore

diff  --git a/clang/lib/Format/TokenAnnotator.h 
b/clang/lib/Format/TokenAnnotator.h
index cea9ef78f1b28..3cf2e3817c6a2 100644
--- a/clang/lib/Format/TokenAnnotator.h
+++ b/clang/lib/Format/TokenAnnotator.h
@@ -38,6 +38,7 @@ class AnnotatedLine {
 public:
   AnnotatedLine(const UnwrappedLine )
   : First(Line.Tokens.front().Tok), Level(Line.Level),
+PPLevel(Line.PPLevel),
 MatchingOpeningBlockLineIndex(Line.MatchingOpeningBlockLineIndex),
 MatchingClosingBlockLineIndex(Line.MatchingClosingBlockLineIndex),
 InPPDirective(Line.InPPDirective),
@@ -129,6 +130,7 @@ class AnnotatedLine {
 
   LineType Type;
   unsigned Level;
+  unsigned PPLevel;
   size_t MatchingOpeningBlockLineIndex;
   size_t MatchingClosingBlockLineIndex;
   bool InPPDirective;

diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index d3aa0625d471a..8e1d907208c08 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -60,12 +60,17 @@ class LevelIndentTracker {
 // Update the indent level cache size so that we can rely on it
 // having the right size in adjustToUnmodifiedline.
 skipLine(Line, /*UnknownIndent=*/true);
-if (Line.InPPDirective ||
-(Style.IndentPPDirectives == FormatStyle::PPDIS_BeforeHash &&
- Line.Type == LT_CommentAbovePPDirective)) {
-  unsigned IndentWidth =
+if (Style.IndentPPDirectives != FormatStyle::PPDIS_None &&
+(Line.InPPDirective ||
+ (Style.IndentPPDirectives == FormatStyle::PPDIS_BeforeHash &&
+  Line.Type == LT_CommentAbovePPDirective))) {
+  unsigned PPIndentWidth =
   (Style.PPIndentWidth >= 0) ? Style.PPIndentWidth : Style.IndentWidth;
-  Indent = Line.Level * IndentWidth + AdditionalIndent;
+  Indent = Line.InMacroBody
+   ? Line.PPLevel * PPIndentWidth +
+ (Line.Level - Line.PPLevel) * Style.IndentWidth
+   : Line.Level * PPIndentWidth;
+  Indent += AdditionalIndent;
 } else {
   Indent = getIndent(Line.Level);
 }

diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 18ec0844db3d4..4dc70e2d56c70 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -197,6 +197,7 @@ class ScopedLineState {
 PreBlockLine = std::move(Parser.Line);
 Parser.Line = std::make_unique();
 Parser.Line->Level = PreBlockLine->Level;
+Parser.Line->PPLevel = PreBlockLine->PPLevel;
 Parser.Line->InPPDirective = PreBlockLine->InPPDirective;
 Parser.Line->InMacroBody = PreBlockLine->InMacroBody;
   }
@@ -833,6 +834,9 @@ bool UnwrappedLineParser::mightFitOnOneLine(
 delete SavedToken.Tok;
   }
 
+  // If these change PPLevel needs to be used for get correct indentation.
+  assert(!Line.InMacroBody);
+  assert(!Line.InPPDirective);
   return Line.Level * Style.IndentWidth + Length <= ColumnLimit;
 }
 
@@ -1270,6 +1274,9 @@ void UnwrappedLineParser::parsePPDefine() {
 Line->Level += PPBranchLevel + 1;
   addUnwrappedLine();
   ++Line->Level;
+
+  Line->PPLevel = PPBranchLevel + (IncludeGuard == IG_Defined ? 0 : 1);
+  assert((int)Line->PPLevel >= 0);
   Line->InMacroBody = true;
 
   // Errors during a preprocessor directive can only affect the 

[PATCH] D138376: Use None consistently (NFC)

2022-11-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

LGTM. `enum class NoneType { None = 1 };` is from 
0cd22f9540c0591132ec991c51103cf800cf4e24 (2017) for MSVC workaround. I assume 
it is no longer needed..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138376

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


[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros

2022-11-19 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n added a comment.

In D137181#3938942 , @owenpan wrote:

> In D137181#3938913 , @goldstein.w.n 
> wrote:
>
>> Anything left for me todo (can't imagine I have push access).
>
> See here . We 
> will need your name and email.

Added `[clang-format]` tag to commit message.

Name: Noah Goldstein
email: goldstein@gmail.com

but that is already in the commit info.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137181

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


[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros

2022-11-19 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n updated this revision to Diff 476732.
goldstein.w.n added a comment.



1. Updating D137181 : [clang-format] Don't 
use 'PPIndentWidth' inside multi-line macros #
2. Enter a brief description of the changes included in this update.
3. The first line is used as subject, next lines as comment. #
4. If you intended to create a new revision, use:
5. $ arc diff --create

Add tag to commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137181

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/TokenAnnotator.h
  clang/lib/Format/UnwrappedLineFormatter.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
@@ -5059,6 +5059,213 @@
"  int y = 0;\n"
"}",
style);
+
+  style.IndentPPDirectives = FormatStyle::PPDIS_None;
+  verifyFormat("#ifdef foo\n"
+   "#define bar() \\\n"
+   "if (A) {  \\\n"
+   "B();  \\\n"
+   "} \\\n"
+   "C();\n"
+   "#endif",
+   style);
+  verifyFormat("if (emacs) {\n"
+   "#ifdef is\n"
+   "#define lit   \\\n"
+   "if (af) { \\\n"
+   "return duh(); \\\n"
+   "}\n"
+   "#endif\n"
+   "}",
+   style);
+  verifyFormat("#if abc\n"
+   "#ifdef foo\n"
+   "#define bar()\\\n"
+   "if (A) { \\\n"
+   "if (B) { \\\n"
+   "C(); \\\n"
+   "}\\\n"
+   "}\\\n"
+   "D();\n"
+   "#endif\n"
+   "#endif",
+   style);
+  verifyFormat("#ifndef foo\n"
+   "#define foo\n"
+   "if (emacs) {\n"
+   "#ifdef is\n"
+   "#define lit   \\\n"
+   "if (af) { \\\n"
+   "return duh(); \\\n"
+   "}\n"
+   "#endif\n"
+   "}\n"
+   "#endif",
+   style);
+  verifyFormat("#if 1\n"
+   "#define X  \\\n"
+   "{  \\\n"
+   "x; \\\n"
+   "x; \\\n"
+   "}\n"
+   "#endif",
+   style);
+  verifyFormat("#define X  \\\n"
+   "{  \\\n"
+   "x; \\\n"
+   "x; \\\n"
+   "}",
+   style);
+
+  style.PPIndentWidth = 2;
+  verifyFormat("#ifdef foo\n"
+   "#define bar() \\\n"
+   "if (A) {  \\\n"
+   "B();  \\\n"
+   "} \\\n"
+   "C();\n"
+   "#endif",
+   style);
+  style.IndentWidth = 8;
+  verifyFormat("#ifdef foo\n"
+   "#define bar()\\\n"
+   "if (A) { \\\n"
+   "B(); \\\n"
+   "}\\\n"
+   "C();\n"
+   "#endif",
+   style);
+
+  style.IndentWidth = 1;
+  style.PPIndentWidth = 4;
+  verifyFormat("#if 1\n"
+   "#define X \\\n"
+   " {\\\n"
+   "  x;  \\\n"
+   "  x;  \\\n"
+   " }\n"
+   "#endif",
+   style);
+  verifyFormat("#define X \\\n"
+   " {\\\n"
+   "  x;  \\\n"
+   "  x;  \\\n"
+   " }",
+   style);
+
+  style.IndentWidth = 4;
+  style.PPIndentWidth = 1;
+  style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  verifyFormat("#ifdef foo\n"
+   "# define bar() \\\n"
+   " if (A) {  \\\n"
+   " B();  \\\n"
+   " } \\\n"
+   " C();\n"
+   "#endif",
+   style);
+  verifyFormat("#if abc\n"
+   "# ifdef foo\n"
+   "#  define bar()\\\n"
+   "  if (A) { \\\n"
+   "  if (B) { \\\n"
+   "  C(); \\\n"
+   "  }\\\n"
+   "  }\\\n"
+   "  D();\n"
+   "# endif\n"
+   "#endif",
+   style);
+  verifyFormat("#ifndef foo\n"
+   "#define foo\n"
+   "if (emacs) {\n"
+   "#ifdef is\n"
+   "# define lit   

[PATCH] D138377: add clang_Type_getFullyQualifiedName

2022-11-19 Thread Anders Langlands via Phabricator via cfe-commits
anderslanglands created this revision.
anderslanglands added a reviewer: aaron.ballman.
Herald added a subscriber: arphaman.
Herald added a project: All.
anderslanglands requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Not sure how to test this - adding it to c-index-test's PrintType will change 
*everything*, which doesn't seem like a great idea.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138377

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang-c/Index.h
  clang/tools/libclang/CXType.cpp
  clang/tools/libclang/libclang.map


Index: clang/tools/libclang/libclang.map
===
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -413,6 +413,7 @@
 clang_CXXMethod_isDeleted;
 clang_CXXMethod_isCopyAssignmentOperator;
 clang_CXXMethod_isMoveAssignmentOperator;
+clang_Type_getFullyQualifiedName;
 };
 
 # Example of how to add a new symbol version entry.  If you do add a new symbol
Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/Type.h"
+#include "clang/AST/QualTypeNames.h"
 #include "clang/Basic/AddressSpaces.h"
 #include "clang/Frontend/ASTUnit.h"
 
@@ -309,6 +310,22 @@
   return cxstring::createDup(OS.str());
 }
 
+CXString clang_Type_getFullyQualifiedName(CXType CT) {
+  QualType T = GetQualType(CT);
+  if (T.isNull())
+return cxstring::createEmpty();
+
+  CXTranslationUnit TU = GetTU(CT);
+  SmallString<64> Str;
+  llvm::raw_svector_ostream OS(Str);
+  PrintingPolicy PP(cxtu::getASTUnit(TU)->getASTContext().getLangOpts());
+
+  std::string qname = clang::TypeName::getFullyQualifiedName(
+  T, cxtu::getASTUnit(TU)->getASTContext(), PP);
+
+  return cxstring::createDup(qname);
+}
+
 CXType clang_getTypedefDeclUnderlyingType(CXCursor C) {
   using namespace cxcursor;
   CXTranslationUnit TU = cxcursor::getCursorTU(C);
Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -2846,6 +2846,13 @@
  */
 CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT);
 
+/**
+ * Get the fully qualified name for a type.
+ *
+ * This includes full qualification of all template parameters.
+*/
+CINDEX_LINKAGE CXString clang_Type_getFullyQualifiedName(CXType CT);
+
 /**
  * Retrieve the underlying type of a typedef declaration.
  *
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -810,6 +810,8 @@
   is a replacement for a template type parameter (previously reported a 
``CXType_Unexposed``).
 - Introduced the new function ``clang_Type_getReplacementType`` which gets the 
type replacing
   the template type parameter when type kind is 
``CXType_SubstTemplateTypeParm``.
+- Introduced the new function ``clang_Type_getFullyQualifiedName``, which gets 
the fully
+  qualified name of the given type, including qualification of all template 
parameters.
 
 Static Analyzer
 ---


Index: clang/tools/libclang/libclang.map
===
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -413,6 +413,7 @@
 clang_CXXMethod_isDeleted;
 clang_CXXMethod_isCopyAssignmentOperator;
 clang_CXXMethod_isMoveAssignmentOperator;
+clang_Type_getFullyQualifiedName;
 };
 
 # Example of how to add a new symbol version entry.  If you do add a new symbol
Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/Type.h"
+#include "clang/AST/QualTypeNames.h"
 #include "clang/Basic/AddressSpaces.h"
 #include "clang/Frontend/ASTUnit.h"
 
@@ -309,6 +310,22 @@
   return cxstring::createDup(OS.str());
 }
 
+CXString clang_Type_getFullyQualifiedName(CXType CT) {
+  QualType T = GetQualType(CT);
+  if (T.isNull())
+return cxstring::createEmpty();
+
+  CXTranslationUnit TU = GetTU(CT);
+  SmallString<64> Str;
+  llvm::raw_svector_ostream OS(Str);
+  PrintingPolicy PP(cxtu::getASTUnit(TU)->getASTContext().getLangOpts());
+
+  std::string qname = clang::TypeName::getFullyQualifiedName(
+  T, cxtu::getASTUnit(TU)->getASTContext(), PP);
+
+  return cxstring::createDup(qname);
+}
+
 CXType clang_getTypedefDeclUnderlyingType(CXCursor C) {
   using namespace cxcursor;
   CXTranslationUnit TU = cxcursor::getCursorTU(C);
Index: clang/include/clang-c/Index.h

[PATCH] D138376: Use None consistently (NFC)

2022-11-19 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added subscribers: Moerafaat, zero9178, mtrofin, bzcheeseman, ayermolo, 
sdasgup3, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, 
jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, 
antiagainst, shauheen, rriddle, mehdi_amini, pengfei, hiraditya.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
kazu requested review of this revision.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, yota9, 
stephenneuendorffer, nicolasvasilache, MaskRay.
Herald added a reviewer: nicolasvasilache.
Herald added projects: clang, LLDB, MLIR, LLVM.

This patch replaces NoneType() and NoneType::None with None in
preparation for migration from llvm::Optional to std::optional.

In the std::optional world, we are not guranteed to be able to
default-construct std::nullopt_t or peek what's inside it, so neither
NoneType() nor NoneType::None has a corresponding expression in the
std::optional world.

Once we consistently use None, we should even be able to replace the
contents of llvm/include/llvm/ADT/None.h with something like:

  using NoneType = std::nullopt_t;
  inline constexpr std::nullopt_t None = std::nullopt;

to ease the migration from llvm::Optional to std::optional.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138376

Files:
  bolt/include/bolt/Core/BinaryContext.h
  bolt/include/bolt/Core/BinaryFunction.h
  bolt/include/bolt/Core/MCPlusBuilder.h
  bolt/lib/Core/BinaryContext.cpp
  bolt/lib/Core/MCPlusBuilder.cpp
  bolt/lib/Profile/BoltAddressTranslation.cpp
  bolt/lib/Profile/DataAggregator.cpp
  bolt/lib/Profile/DataReader.cpp
  bolt/lib/Rewrite/RewriteInstance.cpp
  bolt/lib/Target/X86/X86MCPlusBuilder.cpp
  bolt/lib/Utils/Utils.cpp
  clang/lib/Driver/ToolChains/HLSL.cpp
  lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
  llvm/include/llvm/Analysis/InlineAdvisor.h
  llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/CodeGen/RemoveRedundantDebugValues.cpp
  llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
  llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp
  llvm/unittests/IR/MetadataTest.cpp
  mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Index: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
===
--- mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -312,12 +312,12 @@
   if (parser.parseOperand(*chunkSize) || parser.parseColonType(chunkType))
 return failure();
 } else {
-  chunkSize = llvm::NoneType::None;
+  chunkSize = llvm::None;
 }
 break;
   case ClauseScheduleKind::Auto:
   case ClauseScheduleKind::Runtime:
-chunkSize = llvm::NoneType::None;
+chunkSize = llvm::None;
   }
 
   // If there is a comma, we have one or more modifiers..
Index: llvm/unittests/IR/MetadataTest.cpp
===
--- llvm/unittests/IR/MetadataTest.cpp
+++ llvm/unittests/IR/MetadataTest.cpp
@@ -3683,9 +3683,9 @@
   DILocalVariable *VarB =
   DILocalVariable::get(Context, Scope, "B", File, 7, Type, 3, Flags, 8, nullptr);
 
-  DebugVariable DebugVariableA(VarA, NoneType(), nullptr);
-  DebugVariable DebugVariableInlineA(VarA, NoneType(), InlinedLoc);
-  DebugVariable DebugVariableB(VarB, NoneType(), nullptr);
+  DebugVariable DebugVariableA(VarA, None, nullptr);
+  DebugVariable DebugVariableInlineA(VarA, None, InlinedLoc);
+  DebugVariable DebugVariableB(VarB, None, nullptr);
   DebugVariable DebugVariableFragB(VarB, {{16, 16}}, nullptr);
 
   DebugVariableMap.insert({DebugVariableA, 2});
Index: llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp
@@ -159,7 +159,7 @@
 return Instr;
   }
 }
-return NoneType();
+return None;
   };
 
   std::unique_ptr Ctx = DWARFContext::create(E);
Index: llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
===
--- llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -428,8 +428,7 @@
   VariableMap;
   for (auto  : *BB) {
 if (DbgValueInst *DVI = dyn_cast()) {
-  DebugVariable Key(DVI->getVariable(),
-NoneType(),
+  DebugVariable Key(DVI->getVariable(), None,
 DVI->getDebugLoc()->getInlinedAt());
   auto VMI = VariableMap.find(Key);
   auto *DAI = dyn_cast(DVI);
@@ -490,7 +489,7 @@
   DenseSet SeenDefForAggregate;
   // Returns the DebugVariable for DVI with no fragment info.
   auto GetAggregateVariable = 

[PATCH] D138373: [clang-format] Don't eat two semicolons after namespace

2022-11-19 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: owenpan, MyDeveloperDay, rymiel.
HazardyKnusperkeks added a project: clang-format.
Herald added a project: All.
HazardyKnusperkeks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Remove the double check, move the comment.

This changes behavior, but I think for the better. Despite the comment my 
personal opinion would be to not even gracefully handle the one semicolon, it 
shouldn't be there.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138373

Files:
  clang/lib/Format/UnwrappedLineParser.cpp


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2989,6 +2989,8 @@
 FormatToken *LBrace = FormatTok;
 LBrace->setFinalizedType(TT_NamespaceLBrace);
 
+// Munch the semicolon after a namespace. This is more common than one 
would
+// think. Putting the semicolon into its own line is very ugly.
 parseBlock(/*MustBeDeclaration=*/true, AddLevels, /*MunchSemi=*/true,
/*KeepBraces=*/nullptr, /*IfKind=*/nullptr,
ManageWhitesmithsBraces);
@@ -2996,11 +2998,6 @@
 if (LBrace->MatchingParen)
   LBrace->MatchingParen->setFinalizedType(TT_NamespaceRBrace);
 
-// Munch the semicolon after a namespace. This is more common than one 
would
-// think. Putting the semicolon into its own line is very ugly.
-if (FormatTok->is(tok::semi))
-  nextToken();
-
 addUnwrappedLine(AddLevels > 0 ? LineLevel::Remove : LineLevel::Keep);
 
 if (ManageWhitesmithsBraces)


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2989,6 +2989,8 @@
 FormatToken *LBrace = FormatTok;
 LBrace->setFinalizedType(TT_NamespaceLBrace);
 
+// Munch the semicolon after a namespace. This is more common than one would
+// think. Putting the semicolon into its own line is very ugly.
 parseBlock(/*MustBeDeclaration=*/true, AddLevels, /*MunchSemi=*/true,
/*KeepBraces=*/nullptr, /*IfKind=*/nullptr,
ManageWhitesmithsBraces);
@@ -2996,11 +2998,6 @@
 if (LBrace->MatchingParen)
   LBrace->MatchingParen->setFinalizedType(TT_NamespaceRBrace);
 
-// Munch the semicolon after a namespace. This is more common than one would
-// think. Putting the semicolon into its own line is very ugly.
-if (FormatTok->is(tok::semi))
-  nextToken();
-
 addUnwrappedLine(AddLevels > 0 ? LineLevel::Remove : LineLevel::Keep);
 
 if (ManageWhitesmithsBraces)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138263: [clang-format] Supress aligning of trailing namespace comments

2022-11-19 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 476722.
HazardyKnusperkeks added a comment.

Now with the annotated paren.


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

https://reviews.llvm.org/D138263

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestComments.cpp

Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -68,6 +68,20 @@
 EXPECT_EQ(Code.str(), format(test::messUp(Code), Style));
   }
 
+  void verifyFormat(llvm::StringRef Expected, llvm::StringRef Code,
+const FormatStyle  = getLLVMStyle()) {
+EXPECT_EQ(Expected.str(), format(Expected, Style))
+<< "Expected code is not stable";
+EXPECT_EQ(Expected.str(), format(test::messUp(Code), Style));
+  }
+
+  void verifyFormatWithoutMessUp(llvm::StringRef Expected, llvm::StringRef Code,
+ const FormatStyle  = getLLVMStyle()) {
+EXPECT_EQ(Expected.str(), format(Expected, Style))
+<< "Expected code is not stable";
+EXPECT_EQ(Expected.str(), format(Code, Style));
+  }
+
   void verifyGoogleFormat(llvm::StringRef Code) {
 verifyFormat(Code, getGoogleStyle());
   }
@@ -3076,6 +3090,55 @@
Style));
 }
 
+TEST_F(FormatTestComments, DontAlignNamespaceComments) {
+  FormatStyle Style = getLLVMStyle();
+  Style.NamespaceIndentation = FormatStyle::NI_All;
+  Style.NamespaceMacros.push_back("TESTSUITE");
+  Style.ShortNamespaceLines = 0;
+
+  llvm::StringRef Input = "namespace A {\n"
+  "  TESTSUITE(B) {\n"
+  "namespace C {\n"
+  "  namespace D {} // namespace D\n"
+  "  std::string Foo = Bar; // Comment\n"
+  "}  // namespace C\n"
+  "  }\n"
+  "} // NaMeSpAcE A";
+
+  EXPECT_EQ(Style.AlignTrailingComments.Kind, FormatStyle::TCAS_Always);
+  verifyFormat("namespace A {\n"
+   "  TESTSUITE(B) {\n"
+   "namespace C {\n"
+   "  namespace D {} // namespace D\n"
+   "  std::string Foo = Bar; // Comment\n"
+   "} // namespace C\n"
+   "  } // TESTSUITE(B)\n"
+   "} // NaMeSpAcE A",
+   Input, Style);
+
+  Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Never;
+  verifyFormat("namespace A {\n"
+   "  TESTSUITE(B) {\n"
+   "namespace C {\n"
+   "  namespace D {} // namespace D\n"
+   "  std::string Foo = Bar; // Comment\n"
+   "} // namespace C\n"
+   "  } // TESTSUITE(B)\n"
+   "} // NaMeSpAcE A",
+   Input, Style);
+
+  Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Leave;
+  verifyFormatWithoutMessUp("namespace A {\n"
+"  TESTSUITE(B) {\n"
+"namespace C {\n"
+"  namespace D {} // namespace D\n"
+"  std::string Foo = Bar; // Comment\n"
+"}  // namespace C\n"
+"  }// TESTSUITE(B)\n"
+"} // NaMeSpAcE A",
+Input, Style);
+}
+
 TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
   EXPECT_EQ("/*\n"
 " */",
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19221,7 +19221,7 @@
"  int x;\n"
"  };\n"
"} // namespace b\n"
-   "  }   // namespace a",
+   "  } // namespace a",
WhitesmithsBraceStyle);
 
   verifyFormat("void f()\n"
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -985,11 +985,10 @@
 
 if (i + 1 != e && Changes[i + 1].ContinuesPPDirective)
   ChangeMaxColumn -= 2;
-// If this comment follows an } in column 0, it probably documents the
-// closing of a namespace and we don't want to align it.
-bool FollowsRBraceInColumn0 = i > 0 && Changes[i].NewlinesBefore == 0 &&
-  Changes[i - 1].Tok->is(tok::r_brace) &&
-  Changes[i - 1].StartOfTokenColumn == 0;
+
+// We don't want to align namespace end comments.
+bool DontAlignThisComment =
+i > 0 && 

[PATCH] D138371: [clang-format] Fix a crash due to dereferencing null MatchingParen

2022-11-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 476719.
owenpan added a comment.

Added a test case.


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

https://reviews.llvm.org/D138371

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -26065,6 +26065,8 @@
"}",
Style);
 
+  verifyIncompleteFormat("class C final [[deprecated(l]] {});", Style);
+
   // These tests are here to show a problem that may not be easily
   // solved, our implementation to remove semicolons is only as good
   // as our FunctionLBrace detection and this fails for empty braces
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2852,6 +2852,8 @@
   return false;
   } else if (isCppAttribute(IsCpp, *Next)) {
 Next = Next->MatchingParen;
+if (!Next)
+  return false;
   } else if (Next->is(tok::l_paren)) {
 break;
   } else {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -26065,6 +26065,8 @@
"}",
Style);
 
+  verifyIncompleteFormat("class C final [[deprecated(l]] {});", Style);
+
   // These tests are here to show a problem that may not be easily
   // solved, our implementation to remove semicolons is only as good
   // as our FunctionLBrace detection and this fails for empty braces
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2852,6 +2852,8 @@
   return false;
   } else if (isCppAttribute(IsCpp, *Next)) {
 Next = Next->MatchingParen;
+if (!Next)
+  return false;
   } else if (Next->is(tok::l_paren)) {
 break;
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138371: [clang-format] Fix a crash due to dereferencing null MatchingParen

2022-11-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: HazardyKnusperkeks, MyDeveloperDay, rymiel.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/59089.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138371

Files:
  clang/lib/Format/TokenAnnotator.cpp


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2852,6 +2852,8 @@
   return false;
   } else if (isCppAttribute(IsCpp, *Next)) {
 Next = Next->MatchingParen;
+if (!Next)
+  return false;
   } else if (Next->is(tok::l_paren)) {
 break;
   } else {


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2852,6 +2852,8 @@
   return false;
   } else if (isCppAttribute(IsCpp, *Next)) {
 Next = Next->MatchingParen;
+if (!Next)
+  return false;
   } else if (Next->is(tok::l_paren)) {
 break;
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138179: MIPS: fix build from IR files, nan2008 and FpAbi

2022-11-19 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 476716.

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

https://reviews.llvm.org/D138179

Files:
  clang/lib/Driver/ToolChains/Arch/Mips.cpp
  clang/test/Driver/mips-as.c
  clang/test/Driver/mips-integrated-as.s
  llvm/lib/Target/Mips/MipsAsmPrinter.cpp
  llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll

Index: llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
@@ -0,0 +1,13 @@
+; RUN: llc %s -o - | FileCheck %s
+
+target triple = "mipsel-unknown-linux-gnu"
+
+define dso_local void @test() #0 {
+  ret void
+}
+
+attributes #0 = { "target-cpu"="mips32r2" "target-features"="+fp64,+mips32r2,+nan2008" }
+
+
+; CHECK: .nan2008
+; CHECK: .module fp=64
Index: llvm/lib/Target/Mips/MipsAsmPrinter.cpp
===
--- llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -399,6 +399,14 @@
 
 void MipsAsmPrinter::emitFunctionEntryLabel() {
   MipsTargetStreamer  = getTargetStreamer();
+  bool IsO32 = (static_cast(TM)).getABI().IsO32();
+
+  TS.updateABIInfo(*Subtarget);
+  if (Subtarget->isNaN2008())
+TS.emitDirectiveNaN2008();
+  if ((IsO32 && (Subtarget->isABI_FPXX() || Subtarget->isFP64bit())) ||
+  Subtarget->useSoftFloat())
+TS.emitDirectiveModuleFP();
 
   // NaCl sandboxing requires that indirect call instructions are masked.
   // This means that function entry points should be bundle-aligned.
Index: clang/test/Driver/mips-integrated-as.s
===
--- clang/test/Driver/mips-integrated-as.s
+++ clang/test/Driver/mips-integrated-as.s
@@ -160,8 +160,8 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=FPXX-DEFAULT %s
 // FPXX-DEFAULT: -cc1as
-// FPXX-DEFAULT-NOT: "-target-feature" "+fpxx"
-// FPXX-DEFAULT-NOT: "-target-feature" "+nooddspreg"
+// FPXX-DEFAULT: "-target-feature" "+fpxx"
+// FPXX-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mfp32 2>&1 | \
 // RUN:   FileCheck -check-prefix=FP32 %s
@@ -182,7 +182,7 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-DEFAULT %s
 // ODDSPREG-DEFAULT: -cc1as
-// ODDSPREG-DEFAULT-NOT: "-target-feature" "{{[+-]}}nooddspreg"
+// ODDSPREG-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -modd-spreg 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-ON %s
Index: clang/test/Driver/mips-as.c
===
--- clang/test/Driver/mips-as.c
+++ clang/test/Driver/mips-as.c
@@ -196,7 +196,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-mips16 -mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-16 %s
-// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mips16"
+// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mips16"
 //
 // RUN: %clang -target mips-linux-gnu -mips16 -mno-mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -207,7 +207,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-micromips -mmicromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MICRO %s
-// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmicromips"
+// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mmicromips"
 //
 // RUN: %clang -target mips-linux-gnu -mmicromips -mno-micromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -218,7 +218,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dsp -mdsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSP %s
-// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdsp"
+// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdsp"
 //
 // RUN: %clang -target mips-linux-gnu -mdsp -mno-dsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -229,7 +229,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dspr2 -mdspr2 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSPR2 %s
-// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdspr2"
+// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdspr2"
 //
 // RUN: %clang -target mips-linux-gnu -mdspr2 -mno-dspr2 -### \
 // RUN:   

[PATCH] D138276: TableGen: require tablegen cl::opts to be registered explicitly

2022-11-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: StephenFan.

This is similar to `mlir::register*Options` and looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138276

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


[PATCH] D138274: Add version to all LLVM cmake package

2022-11-19 Thread Stella Laurenzo via Phabricator via cfe-commits
stellaraccident accepted this revision.
stellaraccident added a comment.

As mentioned, the duplication is annoying but I suspect is the least bad way to 
do it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138274

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


[PATCH] D138221: [HIP] Fix lld failure when devie object is empty

2022-11-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> Some host relocatable objects may not contain device relocatable objects, 
> where an empty file is passed to lld, which causes lld to fail.

How is an empty file (size=0) passed to lld? If a dummy relocatable object file 
is parsed to lld, lld can infer the machine type from `e_machine` in the ELF 
header.


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

https://reviews.llvm.org/D138221

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


[PATCH] D138221: [HIP] Fix lld failure when devie object is empty

2022-11-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added inline comments.
This revision now requires changes to proceed.



Comment at: lld/ELF/Driver.cpp:179
   .Case("msp430elf", {ELF32LEKind, EM_MSP430})
+  .Case("elf64_amdgpu", {ELF64LEKind, EM_AMDGPU})
   .Default({ELFNoneKind, EM_NONE});

This needs an `emulation-amdgpu.s` test.


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

https://reviews.llvm.org/D138221

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


[PATCH] D138274: Add version to all LLVM cmake package

2022-11-19 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added a comment.

In D138274#3938218 , @arsenm wrote:

> I thought we had this already. The amount of boiler plate required repeated 
> in each component is depressing, but I wouldn't be surprised if it's really 
> needed

I could configure the LLVMVersion file in llvm/cmake/module directly but I 
would need to refer to it from all those modified CMakeLists.txt and it didn't 
feel very clean either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138274

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


[PATCH] D138179: MIPS: fix build from IR files, nan2008 and FpAbi

2022-11-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.



Comment at: llvm/lib/Target/Mips/MipsAsmPrinter.cpp:402
   MipsTargetStreamer  = getTargetStreamer();
 
+  const MipsTargetMachine  = static_cast(TM);

delete blank line



Comment at: llvm/lib/Target/Mips/MipsAsmPrinter.cpp:404
+  const MipsTargetMachine  = static_cast(TM);
+  const MipsABIInfo  = MTM.getABI();
+

If `ABI` only used once, avoid the variable


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

https://reviews.llvm.org/D138179

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


[PATCH] D134687: [clang] Ensure correct metadata for relative vtables

2022-11-19 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson 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/D134687/new/

https://reviews.llvm.org/D134687

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


[PATCH] D137217: [LTO][COFF] Use bitcode file names in lto native object file names.

2022-11-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:846
+  auto AddStream = [&](size_t Task,
+   Twine ModuleName) -> std::unique_ptr {
 int FD = -1;

`Twine` should only be used as const references as arguments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137217

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


[clang] d116378 - Remove unused llvm/IRPrinter/IRPrintingPasses.h or reorder #include after D137768

2022-11-19 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-11-19T22:09:05Z
New Revision: d1163784b5029b4c21ed861d78881d907389b7b7

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

LOG: Remove unused llvm/IRPrinter/IRPrintingPasses.h or reorder #include after 
D137768

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
llvm/tools/llc/llc.cpp
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index d6a7a9800ec5..d0cab0ceb4d3 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -31,12 +31,12 @@
 #include "llvm/CodeGen/TargetSubtargetInfo.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DebugInfo.h"
-#include "llvm/IRPrinter/IRPrintingPasses.h"
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/ModuleSummaryIndex.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/Verifier.h"
+#include "llvm/IRPrinter/IRPrintingPasses.h"
 #include "llvm/LTO/LTOBackend.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/SubtargetFeature.h"

diff  --git a/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h 
b/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
index 95625d13021e..48aa4b034fee 100644
--- a/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
@@ -29,9 +29,9 @@
 #include "llvm/CodeGen/PreISelIntrinsicLowering.h"
 #include "llvm/CodeGen/ReplaceWithVeclib.h"
 #include "llvm/CodeGen/UnreachableBlockElim.h"
-#include "llvm/IRPrinter/IRPrintingPasses.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/Verifier.h"
+#include "llvm/IRPrinter/IRPrintingPasses.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCTargetOptions.h"
 #include "llvm/Support/CodeGen.h"

diff  --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index efc9b0c502e5..da4a98c056f5 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -28,7 +28,6 @@
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/IRPrinter/IRPrintingPasses.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/LLVMRemarkStreamer.h"
 #include "llvm/IR/LegacyPassManager.h"

diff  --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index 4e6a501a4f0a..3bf6333a9ed0 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -21,11 +21,11 @@
 #include "llvm/Bitcode/BitcodeWriterPass.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/Dominators.h"
-#include "llvm/IRPrinter/IRPrintingPasses.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/Verifier.h"
+#include "llvm/IRPrinter/IRPrintingPasses.h"
 #include "llvm/Passes/PassBuilder.h"
 #include "llvm/Passes/PassPlugin.h"
 #include "llvm/Passes/StandardInstrumentations.h"



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


[PATCH] D137205: [clang-tidy] Add performance-unnecessary-copy-on-last-use check

2022-11-19 Thread Oliver Stöneberg via Phabricator via cfe-commits
firewave added a comment.

In D137205#3936944 , @firewave wrote:

> I still have another false positive with static variables but have not gotten 
> around reducing it yet.

Those false positives no longer appear. So no more open FPs from my side. Great 
work!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137205

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


[PATCH] D137101: [CodeView] Replace GHASH hasher by BLAKE3

2022-11-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.
Herald added a subscriber: StephenFan.

LGTM, I switched to blake3 for --build-id={md5,sha1} for ELF :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137101

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


[clang] 2898ba5 - [Basic] Remove deprecated methods in MapEntryOptionalStorage

2022-11-19 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-11-19T12:33:32-08:00
New Revision: 2898ba5d2eb1952dfd816781b3ca8db05e5673ba

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

LOG: [Basic] Remove deprecated methods in MapEntryOptionalStorage

Note that I deprecated these methods on August 8, 2022 in commit
commit 8e207e4c096e89fa5410b519715aba8c20701061.

Added: 


Modified: 
clang/include/clang/Basic/DirectoryEntry.h

Removed: 




diff  --git a/clang/include/clang/Basic/DirectoryEntry.h 
b/clang/include/clang/Basic/DirectoryEntry.h
index 19d52c09dbcce..9ddeb65ef1945 100644
--- a/clang/include/clang/Basic/DirectoryEntry.h
+++ b/clang/include/clang/Basic/DirectoryEntry.h
@@ -133,35 +133,19 @@ template  class MapEntryOptionalStorage {
   void reset() { MaybeRef = optional_none_tag(); }
 
   bool has_value() const { return MaybeRef.hasOptionalValue(); }
-  LLVM_DEPRECATED("Use has_value instead.", "has_value") bool hasValue() const 
{
-return MaybeRef.hasOptionalValue();
-  }
 
   RefTy () & {
 assert(has_value());
 return MaybeRef;
   }
-  LLVM_DEPRECATED("Use value instead.", "value") RefTy () & {
-assert(has_value());
-return MaybeRef;
-  }
   RefTy const () const & {
 assert(has_value());
 return MaybeRef;
   }
-  LLVM_DEPRECATED("Use value instead.", "value")
-  RefTy const () const & {
-assert(has_value());
-return MaybeRef;
-  }
   RefTy &() && {
 assert(has_value());
 return std::move(MaybeRef);
   }
-  LLVM_DEPRECATED("Use value instead.", "value") RefTy &() && {
-assert(has_value());
-return std::move(MaybeRef);
-  }
 
   template  void emplace(Args &&...args) {
 MaybeRef = RefTy(std::forward(args)...);



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


[PATCH] D137101: [CodeView] Replace GHASH hasher by BLAKE3

2022-11-19 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
aganea marked 2 inline comments as done.
Closed by commit rG49e483d3d62f: [CodeView] Replace GHASH hasher by BLAKE3 
(authored by aganea).
Herald added a reviewer: MaskRay.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D137101?vs=472098=476698#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137101

Files:
  clang/docs/ReleaseNotes.rst
  lld/COFF/DebugTypes.cpp
  lld/docs/ReleaseNotes.rst
  llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
  llvm/test/DebugInfo/COFF/global-type-hashes.ll
  llvm/test/DebugInfo/PDB/obj-globalhash.test

Index: llvm/test/DebugInfo/PDB/obj-globalhash.test
===
--- llvm/test/DebugInfo/PDB/obj-globalhash.test
+++ llvm/test/DebugInfo/PDB/obj-globalhash.test
@@ -14,41 +14,41 @@
 ; char**.  Both the local and global hashes should be the same, since the only
 ; back-references are for simple types which have fixed indices.
 CHECK-ONE:   obj-hashes-1
-CHECK-ONE:   TI: 0x1001, LocalHash: {{.*}}, GlobalHash: A7F8CF106F39A384
+CHECK-ONE:   TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 912CE718D99C2F74
 CHECK-ONE:   obj-hashes-2
-CHECK-ONE:   TI: 0x1000, LocalHash: {{.*}}, GlobalHash: A7F8CF106F39A384
+CHECK-ONE:   TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 912CE718D99C2F74
 
 ; int**.  Same as char**, both the local and global hashes should be the same.
 CHECK-TWO:   obj-hashes-1
-CHECK-TWO:   TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 95D0616C5962F4B1
+CHECK-TWO:   TI: 0x1000, LocalHash: {{.*}}, GlobalHash: 20DAD105A7C67E1D
 CHECK-TWO:   obj-hashes-2
-CHECK-TWO:   TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 95D0616C5962F4B1
+CHECK-TWO:   TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 20DAD105A7C67E1D
 
 ; int***. Different local hashes, since the referent type (int**) is not at the
 ; same TypeIndex in both streams.  Same global hash, since they represent the
 ; same record.
 CHECK-THREE: obj-hashes-1
-CHECK-THREE: TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 48D95F14F6176F4F
+CHECK-THREE: TI: 0x1002, LocalHash: {{.*}}, GlobalHash: 09CBAD68AF5C7998
 CHECK-THREE: obj-hashes-2
-CHECK-THREE: TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 48D95F14F6176F4F
+CHECK-THREE: TI: 0x1001, LocalHash: {{.*}}, GlobalHash: 09CBAD68AF5C7998
 
 ; arg list (char**, int***).  Different local hashes, since the parameter types
 ; both occur at different TypeIndices in their respective input streams.  Same
 ; global hash, since the global hash of all referenced types is the same in
 ; both streams.
 CHECK-FOUR:  obj-hashes-1
-CHECK-FOUR:  TI: 0x1003, LocalHash: {{.*}}, GlobalHash: 99410CD14F5EE80D
+CHECK-FOUR:  TI: 0x1003, LocalHash: {{.*}}, GlobalHash: B6A17FFA392FDF6E
 CHECK-FOUR:  obj-hashes-2
-CHECK-FOUR:  TI: 0x1004, LocalHash: {{.*}}, GlobalHash: 99410CD14F5EE80D
+CHECK-FOUR:  TI: 0x1004, LocalHash: {{.*}}, GlobalHash: B6A17FFA392FDF6E
 
 ; double**.  This is only in stream 2, as a means to throw off the indexing.
 CHECK-FIVE:  obj-hashes-1
 CHECK-FIVE:  obj-hashes-2
-CHECK-FIVE:  TI: 0x1003, LocalHash: {{.*}}, GlobalHash: 20691EA9B88584CC
+CHECK-FIVE:  TI: 0x1003, LocalHash: {{.*}}, GlobalHash: 357B0B78DBFB83B4
 
 ; int** (char**, int***).  For the same logic as described in previous records,
 ; these two records have the same global hash but different local hashes.
 CHECK-SIX:   obj-hashes-1
-CHECK-SIX:   TI: 0x1004, LocalHash: {{.*}}, GlobalHash: 7ACF479173341AC1
+CHECK-SIX:   TI: 0x1004, LocalHash: {{.*}}, GlobalHash: 8356432DE786E196
 CHECK-SIX:   obj-hashes-2
-CHECK-SIX:   TI: 0x1005, LocalHash: {{.*}}, GlobalHash: 7ACF479173341AC1
+CHECK-SIX:   TI: 0x1005, LocalHash: {{.*}}, GlobalHash: 8356432DE786E196
Index: llvm/test/DebugInfo/COFF/global-type-hashes.ll
===
--- llvm/test/DebugInfo/COFF/global-type-hashes.ll
+++ llvm/test/DebugInfo/COFF/global-type-hashes.ll
@@ -21,129 +21,142 @@
 
 ; ModuleID = 'foo.cpp'
 source_filename = "foo.cpp"
-target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
+target datalayout = "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32-a:0:32-S32"
 target triple = "i686-pc-windows-msvc19.11.25547"
 
 %struct.Foo = type { i32, i32 }
 
-$"\01??0Foo@@QAE@HH@Z" = comdat any
+$"??0Foo@@QAE@HH@Z" = comdat any
 
-$"\01?method@Foo@@QAEHXZ" = comdat any
+$"?method@Foo@@QAEHXZ" = comdat any
 
-; Function Attrs: noinline norecurse nounwind optnone
-define i32 @main(i32 %argc, i8** %argv) #0 !dbg !8 {
+; Function Attrs: mustprogress noinline norecurse nounwind optnone
+define dso_local noundef i32 @main(i32 noundef %argc, ptr noundef %argv) #0 !dbg !8 {
 entry:
   %retval = alloca i32, align 4
-  %argv.addr 

[clang] 49e483d - [CodeView] Replace GHASH hasher by BLAKE3

2022-11-19 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2022-11-19T15:17:42-05:00
New Revision: 49e483d3d62f6f62beb323e9c4160bab9e0ad619

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

LOG: [CodeView] Replace GHASH hasher by BLAKE3

Previously, we used SHA-1 for hashing the CodeView type records.
SHA-1 in `GloballyHashedType::hashType()` is coming top in the profiles. By 
simply replacing with BLAKE3, the link time is reduced in our case from 15 sec 
to 13 sec. I am only using MSVC .OBJs in this case. As a reference, the 
resulting .PDB is approx 2.1GiB and .EXE is approx 250MiB.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
lld/COFF/DebugTypes.cpp
lld/docs/ReleaseNotes.rst
llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
llvm/test/DebugInfo/COFF/global-type-hashes.ll
llvm/test/DebugInfo/PDB/obj-globalhash.test

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 640c52096c4a1..dcb5f132fce1b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -519,6 +519,8 @@ Windows Support
   ``/guard:cf,nochecks`` in clang-cl) for enabling Control Flow Guard checks
   and generation of address-taken function table.
 
+- Switched from SHA1 to BLAKE3 for PDB type hashing / ``-gcodeview-ghash``
+
 AIX Support
 ---
 * When using ``-shared``, the clang driver now invokes llvm-nm to create an

diff  --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index ff469685fb7fa..6786d064ca8df 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -275,7 +275,7 @@ static bool canUseDebugH(ArrayRef debugH) {
   debugH = debugH.drop_front(sizeof(object::debug_h_header));
   return header->Magic == COFF::DEBUG_HASHES_SECTION_MAGIC &&
  header->Version == 0 &&
- header->HashAlgorithm == uint16_t(GlobalTypeHashAlg::SHA1_8) &&
+ header->HashAlgorithm == uint16_t(GlobalTypeHashAlg::BLAKE3) &&
  (debugH.size() % 8 == 0);
 }
 

diff  --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst
index 744baaf62efcf..0e9029bdcc097 100644
--- a/lld/docs/ReleaseNotes.rst
+++ b/lld/docs/ReleaseNotes.rst
@@ -43,6 +43,8 @@ COFF Improvements
 * The linker command line entry in ``S_ENVBLOCK`` of the PDB is now stripped
   from input files, to align with MSVC behavior.
   (`D137723 `_)
+* Switched from SHA1 to BLAKE3 for PDB type hashing / ``-gcodeview-ghash``
+  (`D137101 `_)
 
 MinGW Improvements
 --

diff  --git a/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h 
b/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
index f49bc9b8e7909..1914f499f0ed4 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h
@@ -61,7 +61,8 @@ struct LocallyHashedType {
 
 enum class GlobalTypeHashAlg : uint16_t {
   SHA1 = 0, // standard 20-byte SHA1 hash
-  SHA1_8// last 8-bytes of standard SHA1 hash
+  SHA1_8,   // last 8-bytes of standard SHA1 hash
+  BLAKE3,   // truncated 8-bytes BLAKE3
 };
 
 /// A globally hashed type represents a hash value that is sufficient to

diff  --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp 
b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 3bb0df4eeac93..7fd38b7b789fc 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -760,7 +760,7 @@ void CodeViewDebug::emitTypeGlobalHashes() {
   OS.AddComment("Section Version");
   OS.emitInt16(0);
   OS.AddComment("Hash Algorithm");
-  OS.emitInt16(uint16_t(GlobalTypeHashAlg::SHA1_8));
+  OS.emitInt16(uint16_t(GlobalTypeHashAlg::BLAKE3));
 
   TypeIndex TI(TypeIndex::FirstNonSimpleIndex);
   for (const auto  : TypeTable.hashes()) {

diff  --git a/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp 
b/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
index fc85d8186eaad..877fde79ddd09 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
@@ -9,7 +9,7 @@
 #include "llvm/DebugInfo/CodeView/TypeHashing.h"
 
 #include "llvm/DebugInfo/CodeView/TypeIndexDiscovery.h"
-#include "llvm/Support/SHA1.h"
+#include "llvm/Support/BLAKE3.h"
 
 using namespace llvm;
 using namespace llvm::codeview;
@@ -35,7 +35,7 @@ GloballyHashedType::hashType(ArrayRef RecordData,
  ArrayRef PreviousIds) {
   SmallVector Refs;
   discoverTypeIndices(RecordData, Refs);
-  SHA1 S;
+  TruncatedBLAKE3<8> S;
   S.init();
   uint32_t Off = 0;
   S.update(RecordData.take_front(sizeof(RecordPrefix)));
@@ -76,6 +76,5 @@ 

[PATCH] D127462: [Clang] Begin implementing Plan 9 C extensions

2022-11-19 Thread Keegan Saunders via Phabricator via cfe-commits
ksaunders added a comment.

Hi Aaron. Unfortunately, I don't feel I can make a great case for why these 
extensions should be in Clang. Although there are users of Plan 9 C extensions, 
I don't see these features being adopted more generally enough to warrant its 
inclusion in Clang which violates the inclusion policy.

To this effect, I tried using libTooling to rewrite Plan 9 C to standard C that 
can be correctly compiled with Clang, but because the AST creation requires 
semantic analysis to run it leaves the AST in a state of disrepair (it can 
parse Plan 9 C, but the analyzer gets confused with duplicate fields and so on).

I'll have to decide if I am going to keep these changes in a Clang fork or 
modify another C compiler for LLVM. Regardless, I believe my diffs for adding 
the Plan 9 calling convention to LLVM still apply (they are simple), so I will 
send them upstream when I feel they are ready.

---

I think it also makes sense to address your questions here for the sake of 
completeness.

> I'm wondering if you could go into a bit more detail about what Automatic 
> embedded structure type decay and Embedded structure type name accesses mean 
> in practice (some code examples would be helpful).

Absolutely. "Automatic embedded structure type decay" and "Embedded structure 
type name accesses" are features best described by example:

  typedef struct Lock Lock;
  typedef struct Rc Rc;
  typedef struct Resource Resource;
  
  struct Lock
  {
int hold;
  };
  
  struct Rc
  {
int references;
  }:
  
  struct Resource
  {
Rc;
Lock;
void *buffer;
size_t size;
  };

Now with "Embedded structure type name accesses" enabled, if we have a value 
like `Resource *r`, we can do `r->Lock`. This simply returns the field as if 
`Lock;` was declared as `Lock Lock;`, but this special declaration also brings 
all names into scope (like an anonymous struct) so we can do `r->hold`. This 
also does NOT work if you declare the field as `struct Lock;`, it must be a 
typedef name.

Further, with "Automatic embedded structure type decay" structure pointers are 
automatically converted into an access of an embedded compatible structure. So 
we have a function like: `void lock(Lock *);` we can call it with `lock(r);` 
and the compiler will automatically search all unnamed structures in `Resource` 
recursively until it finds a matching type. Note that `Lock;` is declared after 
`Rc;`, this is intentional. In standard C it is possible to have a pointer to a 
struct declay to a pointer to the first field in the struct. That is completely 
separate from this extension.

If that was unclear, GCC also supports this functionality and it is documented 
here for a different explanation: 
https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html

> Are you planning to add a new driver for Clang to emulate the Plan 9 compiler 
> driver (similar to how we have a driver for MSVC compatibility)?

For now, no.

Adding the Plan 9 object format to LLD is out-of-scope for this project (this 
was discussed previously 
) so I 
don't think it's necessary to add a new driver, we can just use the generic ELF 
driver.

Similarly, adding the Plan 9 assembler syntax is not necessary either as most 
programs are C so the assembler can be trivially converted as the idea is that 
programs will be compiled with the Plan 9 calling convention and C ABI.

> Are there other extensions planned, or is the list in the summary pretty 
> complete?

No, the listing above is complete.

> Do I understand correctly that plan 9 compatibility mode forces C89 as the 
> language standard mode, or is it expected that users can do things like 
> -std=c2x -fplan9-extensions?

Plan 9 C extensions are not mutually exclusive with C2x so I think that you 
should be allowed to write C2x Plan 9 C. If we did have a Plan 9 driver though, 
it would set `-fplan9-extensions -std=c89` to be as close as possible to the 
Plan 9 compilers functionality.

Cheers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127462

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


[PATCH] D137205: [clang-tidy] Add performance-unnecessary-copy-on-last-use check

2022-11-19 Thread Fabian Keßler via Phabricator via cfe-commits
Febbe added a comment.

In D137205#3923643 , @Skylion007 
wrote:

> The main false positive I also keep seeing is in pybind11 where it suggests 
> call an std::move() for an implicit conversion, but the target of the 
> implicit conversion does not have an rvalue. (In this case, we have a 
> py::object which inherits from py::handle, and is just py::handle with 
> ownership semantics. This allows implicit conversion to a reference at 
> anytime, and therefore std::move has no effect here except to complicate the 
> code a bit.

Can you post preferably a minimal reproducible example?
Alternatively, you could write me again the exact position of the false 
positive. Including the implicit conversion operator.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137205

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


[PATCH] D137818: Add support for querying SubstTemplateTypeParm types

2022-11-19 Thread Anders Langlands via Phabricator via cfe-commits
anderslanglands added a comment.

Arg just noticed an issue: clang_Type_getReplacementType should be in the 
LLVM_16 block in libclang.map not in the LLVM_13 block. I've blown away my 
local branch so don't know how to fix the patch. Shall I just make a new patch 
once this is merged?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137818

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


[PATCH] D137205: [clang-tidy] Add performance-unnecessary-copy-on-last-use check

2022-11-19 Thread Fabian Keßler via Phabricator via cfe-commits
Febbe added a comment.

In D137205#3936944 , @firewave wrote:

> Here's another false positive:
>
>   #include 
>   
>   void f(const std::string&);
>   
>   int main() {
>   std::string s;
>   f(s.empty() ? "<>" : s);
>   }
>
>
>
>   input.cpp:7:26: warning: Parameter 's' is copied on last use, consider 
> moving it instead. [performance-unnecessary-copy-on-last-use]
>   f(s.empty() ? "<>" : s);
>^
>std::move( )

Actually, this is correct:

https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAMzwBtMA7AQwFtMQByARg9KtQYEAysib0QXACx8BBAKoBnTAAUAHpwAMvAFYTStJg1DIApACYAQuYukl9ZATwDKjdAGFUtAK4sGIAKykrgAyeAyYAHI%2BAEaYxCBmAOykAA6oCoRODB7evgGp6ZkCoeFRLLHxSbaY9o4CQgRMxAQ5Pn6BdpgOWQ1NBCWRMXEJyQqNza15HeP9YYPlw0kAlLaoXsTI7BzmAMxhyN5YANQmO25OY8SYrKfYJhoAgvcPl14OR24pJolWj0f/HxSEDG6BAIEuYWAR2YbCWRxAMMwEERcO%2BFhBYLQXgIJzOpzcJzMZjQDFe73MZlxbnx0NYmCpNIpJn8bgYTJ2VkSABFngCjgA/T4QVE/DEoNY4/GMolYMkECkMs60tiKglMllsomnTk8x68gFCz5HEljcwANmNSzR%2Br5/wICDwCgAtLdEbiucaAHRu6yEswmM0adkWE5/W3/MVYyV4pUUtApACeftVXp9MbVRKORGTUqV9sdLp22DT1NjWo1we%2BuoefJtgIgRvN5st1rD4fzztddPdRzFLFQADckchvXSrRy63zIxKUxT%2B0OFbmCSOS9L/RWtRO2yduc860xsagjqgUnEmERiKcuQ2UsaBKazBbkFbRQRQeLsbOifGk0wFBlgDZDd/QnXdtwPbMTzPC8rxvQkzWbZ80WnT8lz9ed6T/ACgNZSswKebcxQhIxlUwbU913LcCIeAdUDwdBjWIJhkE2FICDgk15UfY0UhfHU90eMIcRYJgwmFVsawBMZzzwZAjlogxHHoI5olQTwjiYHsCGILwyKovkjS%2BH4KSYJlKN%2BST/jrZAmJYzA2IgTTTgAMSOFIQEBa0iWiMyuXHCyqw4FZaE4fxeD8DgtFIVBOGpSxfQUNYNnpXYeFIAhNCClYAGsEkCEKOEkcLMuizheAUEANHSzKVjgWAkDQFgUjoOJyEoRrmvoeIDkMYAuA0AbSCwAdZMwAA1PBMAAdwAeVPCK0poWgCDiCqIGiErojCJoE04NLGrYQQZoYWhdsi3gsBEoxxHOoa8Cubohwq27MFULpsS2NKhJqEraDwaImOIBMPCwErtLwFg9qCvgDGABQJumubGChmRBBEMR2CkVH5CUNQSt0Lh9F6lBrGsfR/oqyAVhPOpSU4J0QSvUx4ssLhEiOJ0Zp2cqai6WmXAYdxPDaPQQjmMoKj0NIMlpyY/EJ6WigYAYJeGQnOm6eoZjlvQNdp3pmhVoZ4nV7XhbyU2%2BiNhYTZWRL1k2CRgtC4rbpijgjlUAAOM0nTNSRjQMEj%2Bs9DRQ6OCBcEIEhCR2Lgll4DLzqWHK8v0TgitICKovd8rKuq5PSDqxAQAlFJsTaiAOpa4gIjpThvd9/3A96o4Q7DqLMHwC96L0fg0dEcQsf7nGVHUW6CdIKamPc7hoYKsKs5K92ZuxcucVQKhPZ9v2A564OO/DhtUCamvY/jxOatTsxJE9ABOB/H6fp%2BzXTwrXZzsrbHzpOtFqmAS6vXeheSuTQ4bKEMDUIQCBUBTQWrwauiksgQPCLQaBsDs4IJPp1YYcNmApAUDAggpBEFxFXsIGBcCSpAOQA8YgcMv40IaPgCKvAR7oyHtIEeigx74z0EHYwpNLDk2iJTYU0U2JZGepzbmqwHaY1sG%2BMIKCoGUPgelK4n1eDTyYLPHgzsOCL0waVDg2A3rIEPMQbeTcA7ABYhHbSXgGDZThA2IRNgjhRwvOfBOBc/7X3yhnD%2BvBc7fyqr/LKb8zDBJMZfZOKwhzEAyM4SQQA


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137205

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


[PATCH] D137818: Add support for querying SubstTemplateTypeParm types

2022-11-19 Thread Anders Langlands via Phabricator via cfe-commits
anderslanglands added a comment.

Great, thanks! I've got a couple more things to land once this is merged and 
I've cleaned them up. Do you wanna show me how to do the merge myself?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137818

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


[PATCH] D138300: [clangd] Support type hints for `decltype(expr)` in variable declarations

2022-11-19 Thread v1nh1shungry via Phabricator via cfe-commits
v1nh1shungry updated this revision to Diff 476692.
v1nh1shungry added a comment.

- fix qualifiers
- fix recursive `decltype` (partly)
- support return type


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138300

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1141,6 +1141,29 @@
   ExpectedHint{": int &", "z"});
 }
 
+TEST(TypeHints, Decltype) {
+  assertTypeHints(R"cpp(
+decltype(0) $a[[a]];
+decltype(a) $b[[b]];
+const decltype(0) $c[[c]] = 0;
+  )cpp",
+  ExpectedHint{": int", "a"}, ExpectedHint{": int", "b"},
+  ExpectedHint{": const int", "c"});
+  assertTypeHints(R"cpp(
+decltype(0) $i[[i]] = 0;
+// FIXME: Nice to show `: int &`
+decltype((i)) $a[[a]] = i;
+  )cpp",
+  ExpectedHint{": int", "i"},
+  ExpectedHint{": decltype(0) &", "a"});
+  // FIXME: Support type hints for l/r reference
+  assertTypeHints(R"cpp(
+int i = 0;
+decltype(0) &$a[[a]] = i;
+decltype(0) &&$b[[b]] = 0;
+  )cpp");
+}
+
 TEST(TypeHints, NoQualifiers) {
   assertTypeHints(R"cpp(
 namespace A {
@@ -1274,6 +1297,8 @@
 
 auto f5($noreturn[[)]] {}
 
+decltype(0) f6($ret3[[)]];
+
 // `auto` conversion operator
 struct A {
   operator auto($retConv[[)]] { return 42; }
@@ -1287,7 +1312,7 @@
   )cpp",
   ExpectedHint{"-> int", "ret1a"}, ExpectedHint{"-> int", "ret1b"},
   ExpectedHint{"-> int &", "ret2"}, ExpectedHint{"-> void", "noreturn"},
-  ExpectedHint{"-> int", "retConv"});
+  ExpectedHint{"-> int", "ret3"}, ExpectedHint{"-> int", "retConv"});
 }
 
 TEST(TypeHints, DependentType) {
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -279,10 +279,15 @@
   }
 
   void addReturnTypeHint(FunctionDecl *D, SourceRange Range) {
-auto *AT = D->getReturnType()->getContainedAutoType();
-if (!AT || AT->getDeducedType().isNull())
-  return;
-addTypeHint(Range, D->getReturnType(), /*Prefix=*/"-> ");
+auto RT = D->getReturnType();
+
+if (auto *AT = RT->getContainedAutoType();
+AT && !AT->getDeducedType().isNull())
+  addTypeHint(Range, RT, /*Prefix=*/"-> ");
+
+if (llvm::isa(RT))
+  if (auto UT = getUnderlyingType(RT); !UT->isDependentType())
+addTypeHint(Range, UT, /*Prefix=*/"-> ");
   }
 
   bool VisitVarDecl(VarDecl *D) {
@@ -296,14 +301,24 @@
   return true;
 }
 
-if (D->getType()->getContainedAutoType()) {
-  if (!D->getType()->isDependentType()) {
+auto T = D->getType();
+
+// Show type hint for `decltype(expr)`, e.g.
+// for `decltype(0) i;`, show `decltype(0) i: int;`
+if (llvm::isa(T)) {
+  if (auto UT = getUnderlyingType(T); !UT->isDependentType())
+addTypeHint(D->getLocation(), UT, /*Prefix=*/": ");
+  return true;
+}
+
+if (T->getContainedAutoType()) {
+  if (!T->isDependentType()) {
 // Our current approach is to place the hint on the variable
 // and accordingly print the full type
 // (e.g. for `const auto& x = 42`, print `const int&`).
 // Alternatively, we could place the hint on the `auto`
 // (and then just print the type deduced for the `auto`).
-addTypeHint(D->getLocation(), D->getType(), /*Prefix=*/": ");
+addTypeHint(D->getLocation(), T, /*Prefix=*/": ");
   }
 }
 
@@ -375,6 +390,14 @@
 private:
   using NameVec = SmallVector;
 
+  static QualType getUnderlyingType(QualType T) {
+auto LFQ = T.getLocalFastQualifiers();
+while (const auto *DT = dyn_cast(T))
+  T = DT->getUnderlyingType();
+T.setLocalFastQualifiers(LFQ);
+return T;
+  }
+
   void processCall(const FunctionDecl *Callee,
llvm::ArrayRef Args) {
 if (!Cfg.InlayHints.Parameters || Args.size() == 0 || !Callee)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138358: [clang-format] Match all block braces

2022-11-19 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: owenpan, MyDeveloperDay, rymiel.
HazardyKnusperkeks added a project: clang-format.
Herald added a project: All.
HazardyKnusperkeks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Now every left and right brace of any block (even the block macros) point to 
each other through the `MatchingParen`.

This commit on it self is NFC (as far as I can see), it is a preparation for 
other change(s).

The brace removing part has been rewritten, because that took advantage of the 
`MatchingParen` field.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138358

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h

Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -110,7 +110,8 @@
  const FormatToken *OpeningBrace = nullptr) const;
   FormatToken *parseBlock(bool MustBeDeclaration = false,
   unsigned AddLevels = 1u, bool MunchSemi = true,
-  bool KeepBraces = true, IfStmtKind *IfKind = nullptr,
+  bool *KeepBraces = nullptr,
+  IfStmtKind *IfKind = nullptr,
   bool UnindentWhitesmithsBraces = false,
   bool CanContainBracedList = true,
   TokenType NextLBracesType = TT_Unknown);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -533,7 +533,7 @@
 continue;
   }
   parseBlock(/*MustBeDeclaration=*/false, /*AddLevels=*/1u,
- /*MunchSemi=*/true, /*KeepBraces=*/true, /*IfKind=*/nullptr,
+ /*MunchSemi=*/true, /*KeepBraces=*/nullptr, /*IfKind=*/nullptr,
  /*UnindentWhitesmithsBraces=*/false, CanContainBracedList,
  NextLBracesType);
   ++StatementCount;
@@ -836,9 +836,23 @@
   return Line.Level * Style.IndentWidth + Length <= ColumnLimit;
 }
 
+/// \brief Parses a Block.
+/// \param[in] MustBeDeclaration If the block is for a declaration.
+/// \param[in] AddLevels How many levels should be added to the lines.
+/// \param[in] MunchSemi If a trailing semi should be munched.
+/// \param[in,out] KeepBraces If not provided it's the same as if it is provided
+/// and set to \c true. If provided it will be set to \c true, if the braces of
+/// this block have to be kept (and thus also the braces of the outer scopes).
+/// \param[in] IfKind 
+/// \param[in] UnindentWhitesmithsBraces If the brace has to be unindented,
+/// because of Whitesmith brace indenting.
+/// \param[in] CanContainBracedList If the block can contain braced init lists.
+/// \param[in] NextLBracesType The type for the next found left braces, when
+/// it's set to something different than TT_Unknown.
+/// \return 
 FormatToken *UnwrappedLineParser::parseBlock(
-bool MustBeDeclaration, unsigned AddLevels, bool MunchSemi, bool KeepBraces,
-IfStmtKind *IfKind, bool UnindentWhitesmithsBraces,
+bool MustBeDeclaration, unsigned AddLevels, bool MunchSemi,
+bool *KeepBraces, IfStmtKind *IfKind, bool UnindentWhitesmithsBraces,
 bool CanContainBracedList, TokenType NextLBracesType) {
   auto HandleVerilogBlockLabel = [this]() {
 // ":" name
@@ -932,7 +946,7 @@
 if (WrappedOpeningBrace && FollowedByComment)
   return false;
 const bool HasRequiredIfBraces = IfLBrace && !IfLBrace->Optional;
-if (KeepBraces && !HasRequiredIfBraces)
+if ((!KeepBraces || *KeepBraces) && !HasRequiredIfBraces)
   return false;
 if (Tok->isNot(TT_ElseLBrace) || !HasRequiredIfBraces) {
   const FormatToken *Previous = Tokens->getPreviousToken();
@@ -953,10 +967,13 @@
 }
 return mightFitOnOneLine((*CurrentLines)[Index], Tok);
   };
-  if (RemoveBraces()) {
-Tok->MatchingParen = FormatTok;
-FormatTok->MatchingParen = Tok;
-  }
+  if (RemoveBraces())
+Tok->Optional = FormatTok->Optional = true;
+  else if (KeepBraces)
+*KeepBraces = true;
+
+  Tok->MatchingParen = FormatTok;
+  FormatTok->MatchingParen = Tok;
 
   size_t PPEndHash = computePPHash();
 
@@ -2676,10 +2693,8 @@
   --Line->Level;
 }
 
-static void markOptionalBraces(FormatToken *LeftBrace) {
-  if (!LeftBrace)
-return;
-
+static void markOptionalBraces(FormatToken *LeftBrace, bool Optional) {
+  assert(LeftBrace);
   assert(LeftBrace->is(tok::l_brace));
 
   FormatToken *RightBrace = LeftBrace->MatchingParen;
@@ -2692,8 +2707,8 @@
   assert(RightBrace->MatchingParen == LeftBrace);
   assert(LeftBrace->Optional == RightBrace->Optional);
 
-  LeftBrace->Optional = true;
-  RightBrace->Optional = 

[PATCH] D138357: [clang-format][NFC] Don't add a load of 0es

2022-11-19 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: rymiel, owenpan, MyDeveloperDay.
HazardyKnusperkeks added a project: clang-format.
Herald added a project: All.
HazardyKnusperkeks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Shift is 0 for all non comments, maybe even for comments. Don't add the 0 up to 
three times.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138357

Files:
  clang/lib/Format/WhitespaceManager.cpp


Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -1049,7 +1049,7 @@
   Changes[i].StartOfBlockComment->StartOfTokenColumn -
   Changes[i].StartOfTokenColumn;
 }
-if (Shift < 0)
+if (Shift <= 0)
   continue;
 Changes[i].Spaces += Shift;
 if (i + 1 != Changes.size())


Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -1049,7 +1049,7 @@
   Changes[i].StartOfBlockComment->StartOfTokenColumn -
   Changes[i].StartOfTokenColumn;
 }
-if (Shift < 0)
+if (Shift <= 0)
   continue;
 Changes[i].Spaces += Shift;
 if (i + 1 != Changes.size())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138354: [clang-format][NFC] Remove unneeded braces

2022-11-19 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: owenpan, rymiel, MyDeveloperDay.
HazardyKnusperkeks added a project: clang-format.
Herald added a project: All.
HazardyKnusperkeks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Done by clang-format itself.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138354

Files:
  clang/lib/Format/TokenAnnotator.cpp


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1352,9 +1352,8 @@
   next();
   next(); // Consume first token (so we fix leading whitespace).
   while (CurrentToken) {
-if (IsMarkOrRegion || CurrentToken->Previous->is(TT_BinaryOperator)) {
+if (IsMarkOrRegion || CurrentToken->Previous->is(TT_BinaryOperator))
   CurrentToken->setType(TT_ImplicitStringLiteral);
-}
 next();
   }
 }


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1352,9 +1352,8 @@
   next();
   next(); // Consume first token (so we fix leading whitespace).
   while (CurrentToken) {
-if (IsMarkOrRegion || CurrentToken->Previous->is(TT_BinaryOperator)) {
+if (IsMarkOrRegion || CurrentToken->Previous->is(TT_BinaryOperator))
   CurrentToken->setType(TT_ImplicitStringLiteral);
-}
 next();
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138284: Fix incorrect cast in VisitSYCLUniqueStableNameExpr

2022-11-19 Thread Alexander Richardson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0745b0c0354a: Fix incorrect cast in 
VisitSYCLUniqueStableNameExpr (authored by arichardson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138284

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGenSYCL/unique_stable_name.cpp
  clang/test/CodeGenSYCL/unique_stable_name_windows_diff.cpp

Index: clang/test/CodeGenSYCL/unique_stable_name_windows_diff.cpp
===
--- clang/test/CodeGenSYCL/unique_stable_name_windows_diff.cpp
+++ clang/test/CodeGenSYCL/unique_stable_name_windows_diff.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple spir64-unknown-unknown-sycldevice -aux-triple x86_64-pc-windows-msvc -fsycl-is-device -disable-llvm-passes -fsycl-is-device -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsycl-is-device -disable-llvm-passes -fsycl-is-device -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple spir64-unknown-unknown-sycldevice -aux-triple x86_64-pc-windows-msvc -fsycl-is-device -disable-llvm-passes -fsycl-is-device -emit-llvm %s -o - | FileCheck %s '-D$ADDRSPACE=addrspace(1) '
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsycl-is-device -disable-llvm-passes -fsycl-is-device -emit-llvm %s -o - | FileCheck %s '-D$ADDRSPACE='
 
 
 template
@@ -38,7 +38,7 @@
   // Make sure the following 3 are the same between the host and device compile.
   // Note that these are NOT the same value as eachother, they differ by the
   // signature.
-  // CHECK: private unnamed_addr constant [17 x i8] c"_ZTSZ4mainEUlvE_\00"
-  // CHECK: private unnamed_addr constant [17 x i8] c"_ZTSZ4mainEUliE_\00"
-  // CHECK: private unnamed_addr constant [17 x i8] c"_ZTSZ4mainEUldE_\00"
+  // CHECK: private unnamed_addr [[$ADDRSPACE]]constant [17 x i8] c"_ZTSZ4mainEUlvE_\00"
+  // CHECK: private unnamed_addr [[$ADDRSPACE]]constant [17 x i8] c"_ZTSZ4mainEUliE_\00"
+  // CHECK: private unnamed_addr [[$ADDRSPACE]]constant [17 x i8] c"_ZTSZ4mainEUldE_\00"
 }
Index: clang/test/CodeGenSYCL/unique_stable_name.cpp
===
--- clang/test/CodeGenSYCL/unique_stable_name.cpp
+++ clang/test/CodeGenSYCL/unique_stable_name.cpp
@@ -1,22 +1,22 @@
 // RUN: %clang_cc1 -no-opaque-pointers -triple spir64-unknown-unknown-sycldevice -fsycl-is-device -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s
-// CHECK: @[[LAMBDA_KERNEL3:[^\w]+]] = private unnamed_addr constant [[LAMBDA_K3_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZ4mainEUlPZ4mainEUlvE_E_\00"
-// CHECK: @[[INT1:[^\w]+]] = private unnamed_addr constant [[INT_SIZE:\[[0-9]+ x i8\]]] c"_ZTSi\00"
-// CHECK: @[[STRING:[^\w]+]] = private unnamed_addr constant [[STRING_SIZE:\[[0-9]+ x i8\]]] c"_ZTSAppL_ZZ4mainE1jE_i\00",
-// CHECK: @[[INT2:[^\w]+]] = private unnamed_addr constant [[INT_SIZE]] c"_ZTSi\00"
-// CHECK: @[[LAMBDA_X:[^\w]+]] = private unnamed_addr constant [[LAMBDA_X_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZZ4mainENKUlvE0_clEvEUlvE_\00"
-// CHECK: @[[MACRO_X:[^\w]+]] = private unnamed_addr constant [[MACRO_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZZ4mainENKUlvE0_clEvEUlvE0_\00"
-// CHECK: @[[MACRO_Y:[^\w]+]] =  private unnamed_addr constant [[MACRO_SIZE]] c"_ZTSZZ4mainENKUlvE0_clEvEUlvE1_\00"
-// CHECK: @{{.*}} = private unnamed_addr constant [32 x i8] c"_ZTSZZ4mainENKUlvE0_clEvEUlvE2_\00", align 1
-// CHECK: @{{.*}} = private unnamed_addr constant [32 x i8] c"_ZTSZZ4mainENKUlvE0_clEvEUlvE3_\00", align 1
-// CHECK: @[[MACRO_MACRO_X:[^\w]+]] = private unnamed_addr constant [[MACRO_MACRO_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZZ4mainENKUlvE0_clEvEUlvE4_\00"
-// CHECK: @[[MACRO_MACRO_Y:[^\w]+]] = private unnamed_addr constant [[MACRO_MACRO_SIZE]] c"_ZTSZZ4mainENKUlvE0_clEvEUlvE5_\00"
-// CHECK: @[[INT3:[^\w]+]] = private unnamed_addr constant [[INT_SIZE]] c"_ZTSi\00"
-// CHECK: @[[LAMBDA:[^\w]+]] = private unnamed_addr constant [[LAMBDA_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZZ4mainENKUlvE0_clEvEUlvE_\00"
-// CHECK: @[[LAMBDA_IN_DEP_INT:[^\w]+]] = private unnamed_addr constant [[DEP_INT_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZ28lambda_in_dependent_functionIiEvvEUlvE_\00",
-// CHECK: @[[LAMBDA_IN_DEP_X:[^\w]+]] = private unnamed_addr constant [[DEP_LAMBDA_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZ28lambda_in_dependent_functionIZZ4mainENKUlvE0_clEvEUlvE_EvvEUlvE_\00",
-// CHECK: @[[LAMBDA_NO_DEP:[^\w]+]] = private unnamed_addr constant [[NO_DEP_LAMBDA_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZ13lambda_no_depIidEvT_T0_EUlidE_\00",
-// CHECK: @[[LAMBDA_TWO_DEP:[^\w]+]] = private unnamed_addr constant [[DEP_LAMBDA1_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZ14lambda_two_depIZZ4mainENKUlvE0_clEvEUliE_ZZ4mainENKS0_clEvEUldE_EvvEUlvE_\00",
-// CHECK: @[[LAMBDA_TWO_DEP2:[^\w]+]] = private unnamed_addr constant [[DEP_LAMBDA2_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZ14lambda_two_depIZZ4mainENKUlvE0_clEvEUldE_ZZ4mainENKS0_clEvEUliE_EvvEUlvE_\00",
+// CHECK: 

[clang] 0745b0c - Fix incorrect cast in VisitSYCLUniqueStableNameExpr

2022-11-19 Thread Alex Richardson via cfe-commits

Author: Alex Richardson
Date: 2022-11-19T11:43:17Z
New Revision: 0745b0c0354a0c8e1fefb68a3876d15db6c2e27a

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

LOG: Fix incorrect cast in VisitSYCLUniqueStableNameExpr

Clang language-level address spaces and LLVM pointer address spaces are
not the same thing (even though they will both have a numeric value of
zero in many cases). LangAS is a enum class to avoid implicit conversions,
but eba69b59d1a30dead07da2c279c8ecfd2b62ba9f avoided the compiler error by
adding a `static_cast<>`. While touching this code, simplify it by using
CreatePointerBitCastOrAddrSpaceCast() which is already a no-op if the types
match.

This changes the code generation for spir64 to place the globals in
the sycl_global addreds space, which maps to `addrspace(1)`.

Reviewed By: bader

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/CodeGenSYCL/unique_stable_name.cpp
clang/test/CodeGenSYCL/unique_stable_name_windows_diff.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 7b1337b1be68c..a5f14de42c8ed 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -1630,21 +1630,14 @@ Value *ScalarExprEmitter::VisitExpr(Expr *E) {
 Value *
 ScalarExprEmitter::VisitSYCLUniqueStableNameExpr(SYCLUniqueStableNameExpr *E) {
   ASTContext  = CGF.getContext();
-  llvm::Optional GlobalAS =
-  Context.getTargetInfo().getConstantAddressSpace();
+  unsigned AddrSpace =
+  Context.getTargetAddressSpace(CGF.CGM.GetGlobalConstantAddressSpace());
   llvm::Constant *GlobalConstStr = Builder.CreateGlobalStringPtr(
-  E->ComputeName(Context), "__usn_str",
-  static_cast(GlobalAS.value_or(LangAS::Default)));
+  E->ComputeName(Context), "__usn_str", AddrSpace);
 
-  unsigned ExprAS = Context.getTargetAddressSpace(E->getType());
-
-  if (GlobalConstStr->getType()->getPointerAddressSpace() == ExprAS)
-return GlobalConstStr;
-
-  llvm::PointerType *PtrTy = 
cast(GlobalConstStr->getType());
-  llvm::PointerType *NewPtrTy =
-  llvm::PointerType::getWithSamePointeeType(PtrTy, ExprAS);
-  return Builder.CreateAddrSpaceCast(GlobalConstStr, NewPtrTy, 
"usn_addr_cast");
+  llvm::Type *ExprTy = ConvertType(E->getType());
+  return Builder.CreatePointerBitCastOrAddrSpaceCast(GlobalConstStr, ExprTy,
+ "usn_addr_cast");
 }
 
 Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {

diff  --git a/clang/test/CodeGenSYCL/unique_stable_name.cpp 
b/clang/test/CodeGenSYCL/unique_stable_name.cpp
index d346d3ab407f5..b4e16f4ab1457 100644
--- a/clang/test/CodeGenSYCL/unique_stable_name.cpp
+++ b/clang/test/CodeGenSYCL/unique_stable_name.cpp
@@ -1,22 +1,22 @@
 // RUN: %clang_cc1 -no-opaque-pointers -triple 
spir64-unknown-unknown-sycldevice -fsycl-is-device -disable-llvm-passes 
-emit-llvm %s -o - | FileCheck %s
-// CHECK: @[[LAMBDA_KERNEL3:[^\w]+]] = private unnamed_addr constant 
[[LAMBDA_K3_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZ4mainEUlPZ4mainEUlvE_E_\00"
-// CHECK: @[[INT1:[^\w]+]] = private unnamed_addr constant [[INT_SIZE:\[[0-9]+ 
x i8\]]] c"_ZTSi\00"
-// CHECK: @[[STRING:[^\w]+]] = private unnamed_addr constant 
[[STRING_SIZE:\[[0-9]+ x i8\]]] c"_ZTSAppL_ZZ4mainE1jE_i\00",
-// CHECK: @[[INT2:[^\w]+]] = private unnamed_addr constant [[INT_SIZE]] 
c"_ZTSi\00"
-// CHECK: @[[LAMBDA_X:[^\w]+]] = private unnamed_addr constant 
[[LAMBDA_X_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZZ4mainENKUlvE0_clEvEUlvE_\00"
-// CHECK: @[[MACRO_X:[^\w]+]] = private unnamed_addr constant 
[[MACRO_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZZ4mainENKUlvE0_clEvEUlvE0_\00"
-// CHECK: @[[MACRO_Y:[^\w]+]] =  private unnamed_addr constant [[MACRO_SIZE]] 
c"_ZTSZZ4mainENKUlvE0_clEvEUlvE1_\00"
-// CHECK: @{{.*}} = private unnamed_addr constant [32 x i8] 
c"_ZTSZZ4mainENKUlvE0_clEvEUlvE2_\00", align 1
-// CHECK: @{{.*}} = private unnamed_addr constant [32 x i8] 
c"_ZTSZZ4mainENKUlvE0_clEvEUlvE3_\00", align 1
-// CHECK: @[[MACRO_MACRO_X:[^\w]+]] = private unnamed_addr constant 
[[MACRO_MACRO_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZZ4mainENKUlvE0_clEvEUlvE4_\00"
-// CHECK: @[[MACRO_MACRO_Y:[^\w]+]] = private unnamed_addr constant 
[[MACRO_MACRO_SIZE]] c"_ZTSZZ4mainENKUlvE0_clEvEUlvE5_\00"
-// CHECK: @[[INT3:[^\w]+]] = private unnamed_addr constant [[INT_SIZE]] 
c"_ZTSi\00"
-// CHECK: @[[LAMBDA:[^\w]+]] = private unnamed_addr constant 
[[LAMBDA_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZZ4mainENKUlvE0_clEvEUlvE_\00"
-// CHECK: @[[LAMBDA_IN_DEP_INT:[^\w]+]] = private unnamed_addr constant 
[[DEP_INT_SIZE:\[[0-9]+ x i8\]]] 
c"_ZTSZ28lambda_in_dependent_functionIiEvvEUlvE_\00",
-// CHECK: @[[LAMBDA_IN_DEP_X:[^\w]+]] = private 

[PATCH] D138300: [clangd] Support type hints for `decltype(expr)` in variable declarations

2022-11-19 Thread v1nh1shungry via Phabricator via cfe-commits
v1nh1shungry updated this revision to Diff 476667.
v1nh1shungry added a comment.

Avoid type hints for dependent types


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138300

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp


Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1141,6 +1141,10 @@
   ExpectedHint{": int &", "z"});
 }
 
+TEST(TypeHints, Decltype) {
+  assertTypeHints("decltype(0) $i[[i]];", ExpectedHint{": int", "i"});
+}
+
 TEST(TypeHints, NoQualifiers) {
   assertTypeHints(R"cpp(
 namespace A {
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -296,14 +296,24 @@
   return true;
 }
 
-if (D->getType()->getContainedAutoType()) {
-  if (!D->getType()->isDependentType()) {
+auto T = D->getType();
+
+// Show type hint for `decltype(expr)`, e.g.
+// for `decltype(0) i;`, show `decltype(0) i: int;`
+if (const auto *DT = llvm::dyn_cast(T)) {
+  if (auto UT = DT->getUnderlyingType(); !UT->isDependentType())
+addTypeHint(D->getLocation(), UT, /*Prefix=*/": ");
+  return true;
+}
+
+if (T->getContainedAutoType()) {
+  if (!T->isDependentType()) {
 // Our current approach is to place the hint on the variable
 // and accordingly print the full type
 // (e.g. for `const auto& x = 42`, print `const int&`).
 // Alternatively, we could place the hint on the `auto`
 // (and then just print the type deduced for the `auto`).
-addTypeHint(D->getLocation(), D->getType(), /*Prefix=*/": ");
+addTypeHint(D->getLocation(), T, /*Prefix=*/": ");
   }
 }
 


Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1141,6 +1141,10 @@
   ExpectedHint{": int &", "z"});
 }
 
+TEST(TypeHints, Decltype) {
+  assertTypeHints("decltype(0) $i[[i]];", ExpectedHint{": int", "i"});
+}
+
 TEST(TypeHints, NoQualifiers) {
   assertTypeHints(R"cpp(
 namespace A {
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -296,14 +296,24 @@
   return true;
 }
 
-if (D->getType()->getContainedAutoType()) {
-  if (!D->getType()->isDependentType()) {
+auto T = D->getType();
+
+// Show type hint for `decltype(expr)`, e.g.
+// for `decltype(0) i;`, show `decltype(0) i: int;`
+if (const auto *DT = llvm::dyn_cast(T)) {
+  if (auto UT = DT->getUnderlyingType(); !UT->isDependentType())
+addTypeHint(D->getLocation(), UT, /*Prefix=*/": ");
+  return true;
+}
+
+if (T->getContainedAutoType()) {
+  if (!T->isDependentType()) {
 // Our current approach is to place the hint on the variable
 // and accordingly print the full type
 // (e.g. for `const auto& x = 42`, print `const int&`).
 // Alternatively, we could place the hint on the `auto`
 // (and then just print the type deduced for the `auto`).
-addTypeHint(D->getLocation(), D->getType(), /*Prefix=*/": ");
+addTypeHint(D->getLocation(), T, /*Prefix=*/": ");
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits