clang 20.0.0git
Macros | Functions
ASTDiagnostic.cpp File Reference
#include "clang/AST/ASTDiagnostic.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTLambda.h"
#include "clang/AST/Attr.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/TemplateBase.h"
#include "clang/AST/Type.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "clang/AST/TypeNodes.inc"

Go to the source code of this file.

Macros

#define ABSTRACT_TYPE(Class, Base)
 
#define TYPE(Class, Base)
 

Functions

static std::string ConvertTypeToDiagnosticString (ASTContext &Context, QualType Ty, ArrayRef< DiagnosticsEngine::ArgumentValue > PrevArgs, ArrayRef< intptr_t > QualTypeVals)
 Convert the given type to a string suitable for printing as part of a diagnostic.
 
static bool FormatTemplateTypeDiff (ASTContext &Context, QualType FromType, QualType ToType, bool PrintTree, bool PrintFromType, bool ElideType, bool ShowColors, raw_ostream &OS)
 FormatTemplateTypeDiff - A helper static function to start the template diff and return the properly formatted string.
 

Macro Definition Documentation

◆ ABSTRACT_TYPE

#define ABSTRACT_TYPE (   Class,
  Base 
)

◆ TYPE

#define TYPE (   Class,
  Base 
)
Value:
case Type::Class: { \
const Class##Type *CTy = cast<Class##Type>(Ty); \
if (CTy->isSugared()) { \
IsSugar = true; \
Underlying = CTy->desugar(); \
} \
break; \
}
The base class of the type hierarchy.
Definition: Type.h:1829
@ Class
The "class" keyword introduces the elaborated-type-specifier.

Function Documentation

◆ ConvertTypeToDiagnosticString()

static std::string ConvertTypeToDiagnosticString ( ASTContext Context,
QualType  Ty,
ArrayRef< DiagnosticsEngine::ArgumentValue PrevArgs,
ArrayRef< intptr_t QualTypeVals 
)
static

Convert the given type to a string suitable for printing as part of a diagnostic.

There are four main criteria when determining whether we should have an a.k.a. clause when pretty-printing a type:

1) Some types provide very minimal sugar that doesn't impede the user's understanding — for example, elaborated type specifiers. If this is all the sugar we see, we don't want an a.k.a. clause. 2) Some types are technically sugared but are much more familiar when seen in their sugared form — for example, va_list, vector types, and the magic Objective C types. We don't want to desugar these, even if we do produce an a.k.a. clause. 3) Some types may have already been desugared previously in this diagnostic. if this is the case, doing another "aka" would just be clutter. 4) Two different types within the same diagnostic have the same output string. In this case, force an a.k.a with the desugared type when doing so will provide additional information.

Parameters
Contextthe context in which the type was allocated
Tythe type to print
QualTypeValspointer values to QualTypes which are used in the diagnostic message

Definition at line 264 of file ASTDiagnostic.cpp.

References clang::DiagnosticsEngine::ak_qualtype, clang::desugarForDiagnostic(), clang::Type::getAs(), clang::QualType::getAsString(), clang::QualType::getCanonicalType(), clang::QualType::getFromOpaquePtr(), clang::ASTContext::getPrintingPolicy(), and clang::QualType::isNull().

Referenced by clang::FormatASTNodeDiagnosticArgument().

◆ FormatTemplateTypeDiff()

static bool FormatTemplateTypeDiff ( ASTContext Context,
QualType  FromType,
QualType  ToType,
bool  PrintTree,
bool  PrintFromType,
bool  ElideType,
bool  ShowColors,
raw_ostream &  OS 
)
static

FormatTemplateTypeDiff - A helper static function to start the template diff and return the properly formatted string.

Returns true if the diff is successful.

Definition at line 2160 of file ASTDiagnostic.cpp.

References ShowColors.

Referenced by clang::FormatASTNodeDiagnosticArgument().