clang API Documentation

Defines | 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/SmallString.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.

Defines

#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.
static bool FormatTemplateTypeDiff (ASTContext &Context, QualType FromType, QualType ToType, bool PrintTree, bool PrintFromType, bool ElideType, bool ShowColors, raw_ostream &OS)

Define Documentation

#define ABSTRACT_TYPE (   Class,
  Base 
)
#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; \
}

Function Documentation

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

References clang::DiagnosticsEngine::ak_qualtype, Desugar(), clang::Type::getAs(), clang::QualType::getAsString(), clang::QualType::getCanonicalType(), clang::VectorType::getElementType(), clang::QualType::getFromOpaquePtr(), clang::VectorType::getNumElements(), clang::ASTContext::getPrintingPolicy(), clang::QualType::isNull(), clang::Type::isVectorType(), and S.

Referenced by clang::FormatASTNodeDiagnosticArgument().

static QualType Desugar ( ASTContext Context,
QualType  QT,
bool ShouldAKA 
) [static]
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 1862 of file ASTDiagnostic.cpp.

Referenced by clang::FormatASTNodeDiagnosticArgument().