[clang] 7092398 - Improve pretty-printing for APValues of void type.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 20 17:14:32 PDT 2020


Author: Richard Smith
Date: 2020-08-20T17:14:22-07:00
New Revision: 70923983e54253723600eb2f4cdfb0fbb347a364

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

LOG: Improve pretty-printing for APValues of void type.

No functionality change intended: there doesn't seem to be any way to
cause Clang to print such a value, but they can show up when dumping
APValues from a debugger.

Added: 
    

Modified: 
    clang/lib/AST/APValue.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp
index f3828bb54c1d..2a8834b4db0c 100644
--- a/clang/lib/AST/APValue.cpp
+++ b/clang/lib/AST/APValue.cpp
@@ -388,6 +388,13 @@ static double GetApproxValue(const llvm::APFloat &F) {
 
 void APValue::printPretty(raw_ostream &Out, const ASTContext &Ctx,
                           QualType Ty) const {
+  // There are no objects of type 'void', but values of this type can be
+  // returned from functions.
+  if (Ty->isVoidType()) {
+    Out << "void()";
+    return;
+  }
+
   switch (getKind()) {
   case APValue::None:
     Out << "<out of lifetime>";


        


More information about the cfe-commits mailing list