clang  6.0.0svn
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/Support/raw_ostream.h"
#include "clang/AST/TypeNodes.def"
Include dependency graph for ASTDiagnostic.cpp:

Go to the source code of this file.

Macros

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

Functions

static QualType Desugar (ASTContext &Context, QualType QT, bool &ShouldAKA)
 
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. More...
 
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. More...
 

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:1300

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 228 of file ASTDiagnostic.cpp.

Referenced by clang::FormatASTNodeDiagnosticArgument().

◆ Desugar()

static QualType Desugar ( ASTContext Context,
QualType  QT,
bool ShouldAKA 
)
static

Definition at line 29 of file ASTDiagnostic.cpp.

Referenced by handleObjCGCTypeAttr().

◆ 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 2041 of file ASTDiagnostic.cpp.

Referenced by clang::FormatASTNodeDiagnosticArgument().