[PATCH] D125580: Resolve overload ambiguity on Mac OS when printing size_t in diagnostics

2022-05-14 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac7a9ef0ae3a: Resolve overload ambiguity on Mac OS when 
printing size_t in diagnostics (authored by aaronpuchert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125580

Files:
  clang/include/clang/Basic/Diagnostic.h
  clang/lib/AST/CommentParser.cpp


Index: clang/lib/AST/CommentParser.cpp
===
--- clang/lib/AST/CommentParser.cpp
+++ clang/lib/AST/CommentParser.cpp
@@ -414,7 +414,7 @@
   if (Args.size() < Info->NumArgs) {
 Diag(CommandTok.getEndLocation().getLocWithOffset(1),
  diag::warn_doc_inline_command_not_enough_arguments)
-<< CommandTok.is(tok::at_command) << Info->Name << 
(uint64_t)Args.size()
+<< CommandTok.is(tok::at_command) << Info->Name << Args.size()
 << Info->NumArgs
 << SourceRange(CommandTok.getLocation(), CommandTok.getEndLocation());
   }
Index: clang/include/clang/Basic/Diagnostic.h
===
--- clang/include/clang/Basic/Diagnostic.h
+++ clang/include/clang/Basic/Diagnostic.h
@@ -1404,7 +1404,13 @@
 }
 
 inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
- int64_t I) {
+ long I) {
+  DB.AddTaggedVal(I, DiagnosticsEngine::ak_sint);
+  return DB;
+}
+
+inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
+ long long I) {
   DB.AddTaggedVal(I, DiagnosticsEngine::ak_sint);
   return DB;
 }
@@ -1426,7 +1432,13 @@
 }
 
 inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
- uint64_t I) {
+ unsigned long I) {
+  DB.AddTaggedVal(I, DiagnosticsEngine::ak_uint);
+  return DB;
+}
+
+inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
+ unsigned long long I) {
   DB.AddTaggedVal(I, DiagnosticsEngine::ak_uint);
   return DB;
 }


Index: clang/lib/AST/CommentParser.cpp
===
--- clang/lib/AST/CommentParser.cpp
+++ clang/lib/AST/CommentParser.cpp
@@ -414,7 +414,7 @@
   if (Args.size() < Info->NumArgs) {
 Diag(CommandTok.getEndLocation().getLocWithOffset(1),
  diag::warn_doc_inline_command_not_enough_arguments)
-<< CommandTok.is(tok::at_command) << Info->Name << (uint64_t)Args.size()
+<< CommandTok.is(tok::at_command) << Info->Name << Args.size()
 << Info->NumArgs
 << SourceRange(CommandTok.getLocation(), CommandTok.getEndLocation());
   }
Index: clang/include/clang/Basic/Diagnostic.h
===
--- clang/include/clang/Basic/Diagnostic.h
+++ clang/include/clang/Basic/Diagnostic.h
@@ -1404,7 +1404,13 @@
 }
 
 inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
- int64_t I) {
+ long I) {
+  DB.AddTaggedVal(I, DiagnosticsEngine::ak_sint);
+  return DB;
+}
+
+inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
+ long long I) {
   DB.AddTaggedVal(I, DiagnosticsEngine::ak_sint);
   return DB;
 }
@@ -1426,7 +1432,13 @@
 }
 
 inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
- uint64_t I) {
+ unsigned long I) {
+  DB.AddTaggedVal(I, DiagnosticsEngine::ak_uint);
+  return DB;
+}
+
+inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
+ unsigned long long I) {
   DB.AddTaggedVal(I, DiagnosticsEngine::ak_uint);
   return DB;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125580: Resolve overload ambiguity on Mac OS when printing size_t in diagnostics

2022-05-13 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added reviewers: aeubanks, rsmith.
Herald added a project: All.
aaronpuchert requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Precommit builds cover Linux and Windows, but this ambiguity would only
show up on Mac OS: there we have int32_t = int, int64_t = long long and
size_t = unsigned long. So printing a size_t, while successful on the
other two architectures, cannot be unambiguously resolved on Mac OS.

This is not really meant to support printing arguments of type long or
size_t, but more as a way to prevent build breakage that would not be
detected in precommit builds, as happened in D125429 
.

Technically we have no guarantee that one of these types has the 64 bits
that afdac5fbcb6a3 
 wanted to 
provide, so proposals are welcome. We do
have a guarantee though that these three types are different, so we
should be fine with overload resolution.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125580

Files:
  clang/include/clang/Basic/Diagnostic.h
  clang/lib/AST/CommentParser.cpp


Index: clang/lib/AST/CommentParser.cpp
===
--- clang/lib/AST/CommentParser.cpp
+++ clang/lib/AST/CommentParser.cpp
@@ -414,7 +414,7 @@
   if (Args.size() < Info->NumArgs) {
 Diag(CommandTok.getEndLocation().getLocWithOffset(1),
  diag::warn_doc_inline_command_not_enough_arguments)
-<< CommandTok.is(tok::at_command) << Info->Name << 
(uint64_t)Args.size()
+<< CommandTok.is(tok::at_command) << Info->Name << Args.size()
 << Info->NumArgs
 << SourceRange(CommandTok.getLocation(), CommandTok.getEndLocation());
   }
Index: clang/include/clang/Basic/Diagnostic.h
===
--- clang/include/clang/Basic/Diagnostic.h
+++ clang/include/clang/Basic/Diagnostic.h
@@ -1404,7 +1404,13 @@
 }
 
 inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
- int64_t I) {
+ long I) {
+  DB.AddTaggedVal(I, DiagnosticsEngine::ak_sint);
+  return DB;
+}
+
+inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
+ long long I) {
   DB.AddTaggedVal(I, DiagnosticsEngine::ak_sint);
   return DB;
 }
@@ -1426,7 +1432,13 @@
 }
 
 inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
- uint64_t I) {
+ unsigned long I) {
+  DB.AddTaggedVal(I, DiagnosticsEngine::ak_uint);
+  return DB;
+}
+
+inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
+ unsigned long long I) {
   DB.AddTaggedVal(I, DiagnosticsEngine::ak_uint);
   return DB;
 }


Index: clang/lib/AST/CommentParser.cpp
===
--- clang/lib/AST/CommentParser.cpp
+++ clang/lib/AST/CommentParser.cpp
@@ -414,7 +414,7 @@
   if (Args.size() < Info->NumArgs) {
 Diag(CommandTok.getEndLocation().getLocWithOffset(1),
  diag::warn_doc_inline_command_not_enough_arguments)
-<< CommandTok.is(tok::at_command) << Info->Name << (uint64_t)Args.size()
+<< CommandTok.is(tok::at_command) << Info->Name << Args.size()
 << Info->NumArgs
 << SourceRange(CommandTok.getLocation(), CommandTok.getEndLocation());
   }
Index: clang/include/clang/Basic/Diagnostic.h
===
--- clang/include/clang/Basic/Diagnostic.h
+++ clang/include/clang/Basic/Diagnostic.h
@@ -1404,7 +1404,13 @@
 }
 
 inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
- int64_t I) {
+ long I) {
+  DB.AddTaggedVal(I, DiagnosticsEngine::ak_sint);
+  return DB;
+}
+
+inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
+ long long I) {
   DB.AddTaggedVal(I, DiagnosticsEngine::ak_sint);
   return DB;
 }
@@ -1426,7 +1432,13 @@
 }
 
 inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
- uint64_t I) {
+ unsigned long I) {
+  DB.AddTaggedVal(I, DiagnosticsEngine::ak_uint);
+  return DB;
+}
+
+inline const StreamingDiagnostic <<(const StreamingDiagnostic ,
+ unsigned long long I) {
   DB.AddTaggedVal(I, DiagnosticsEngine::ak_uint);
   return DB;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits