clang 10.0.0git

Classes | Namespaces | Macros | Typedefs | Functions
Sema.cpp File Reference
`#include "clang/AST/ASTContext.h"`
`#include "clang/AST/ASTDiagnostic.h"`
`#include "clang/AST/DeclCXX.h"`
`#include "clang/AST/DeclFriend.h"`
`#include "clang/AST/DeclObjC.h"`
`#include "clang/AST/Expr.h"`
`#include "clang/AST/ExprCXX.h"`
`#include "clang/AST/PrettyDeclStackTrace.h"`
`#include "clang/AST/StmtCXX.h"`
`#include "clang/Basic/DiagnosticOptions.h"`
`#include "clang/Basic/PartialDiagnostic.h"`
`#include "clang/Basic/Stack.h"`
`#include "clang/Basic/TargetInfo.h"`
`#include "clang/Lex/HeaderSearch.h"`
`#include "clang/Lex/Preprocessor.h"`
`#include "clang/Sema/CXXFieldCollector.h"`
`#include "clang/Sema/DelayedDiagnostic.h"`
`#include "clang/Sema/ExternalSemaSource.h"`
`#include "clang/Sema/Initialization.h"`
`#include "clang/Sema/MultiplexExternalSemaSource.h"`
`#include "clang/Sema/ObjCMethodList.h"`
`#include "clang/Sema/Scope.h"`
`#include "clang/Sema/ScopeInfo.h"`
`#include "clang/Sema/SemaConsumer.h"`
`#include "clang/Sema/SemaInternal.h"`
`#include "clang/Sema/TemplateDeduction.h"`
`#include "clang/Sema/TemplateInstCallback.h"`
`#include "clang/Sema/TypoCorrection.h"`
`#include "llvm/ADT/DenseMap.h"`
`#include "llvm/ADT/SmallSet.h"`
`#include "llvm/Support/TimeProfiler.h"`
`#include "clang/Basic/OpenCLImageTypes.def"`
`#include "clang/Basic/OpenCLExtensionTypes.def"`
`#include "clang/Basic/AArch64SVEACLETypes.def"`
Include dependency graph for Sema.cpp:

Go to the source code of this file.

## Classes
class | clang::sema::SemaPPCallbacks

## Namespaces
| clang
| Dataflow Directional Tag Classes.
| clang::sema

## Macros
#define | GENERIC_IMAGE_TYPE_EXT(Type, Id, Ext) setOpenCLExtensionForType(Context.Id, Ext);
#define | EXT_OPAQUE_TYPE(ExtType, Id, Ext)
#define | SVE_TYPE(Name, Id, SingletonId) addImplicitTypedef(Name, Context.SingletonId);

## Typedefs
typedef llvm::DenseMap< const CXXRecordDecl *, bool > | RecordCompleteMap

## Functions
static bool | ShouldRemoveFromUnused (Sema *SemaRef, const DeclaratorDecl *D)
| Used to prune the decls of Sema's UnusedFileScopedDecls vector. More...
static bool | isFunctionOrVarDeclExternC (NamedDecl *ND)
static void | checkUndefinedButUsed (Sema &S)
| checkUndefinedButUsed - Check for undefined objects with internal linkage or that are inline. More...
static bool | MethodsAndNestedClassesComplete (const CXXRecordDecl *RD, RecordCompleteMap &MNCComplete)
| Returns true, if all methods and nested classes of the given CXXRecordDecl are defined in this translation unit. More...
static bool | IsRecordFullyDefined (const CXXRecordDecl *RD, RecordCompleteMap &RecordsComplete, RecordCompleteMap &MNCComplete)
| Returns true, if the given CXXRecordDecl is fully defined in this translation unit, i.e. More...
static void | emitCallStackNotes (Sema &S, FunctionDecl *FD)
static void | emitDeferredDiags (Sema &S, FunctionDecl *FD, bool ShowCallStack)
static void | checkEscapingByref (VarDecl *VD, Sema &S)
static void | markEscapingByrefs (const FunctionScopeInfo &FSI, Sema &S)
static void | noteOverloads (Sema &S, const UnresolvedSetImpl &Overloads, const SourceLocation FinalNoteLoc)
| Give notes for a set of overloads. More...
static void | notePlausibleOverloads (Sema &S, SourceLocation Loc, const UnresolvedSetImpl &Overloads, bool(*IsPlausibleResult)(QualType))
static bool | IsCallableWithAppend (Expr *E)
| Determine whether the given expression can be called by just putting parentheses after it. More...
static bool | IsCPUDispatchCPUSpecificMultiVersion (const Expr *E)

## Macro Definition Documentation

## ◆ EXT_OPAQUE_TYPE

#define EXT_OPAQUE_TYPE | ( |  | ExtType,
|  |  | Id,
|  |  | Ext
| ) |  |

Value:
addImplicitTypedef(#ExtType, Context.Id##Ty); \
setOpenCLExtensionForType(Context.Id##Ty, #Ext);

## ◆ GENERIC_IMAGE_TYPE_EXT

#define GENERIC_IMAGE_TYPE_EXT | ( |  | Type,
|  |  | Id,
|  |  | Ext
| ) |  | setOpenCLExtensionForType(Context.Id, Ext);

## ◆ SVE_TYPE

#define SVE_TYPE | ( |  | Name,
|  |  | Id,
|  |  | SingletonId
| ) |  | addImplicitTypedef(Name, Context.SingletonId);

## Typedef Documentation

## ◆ RecordCompleteMap

typedef llvm::DenseMap<const CXXRecordDecl*, bool> RecordCompleteMap

Definition at line 797 of file Sema.cpp.

## Function Documentation

## ◆ checkEscapingByref()

static void checkEscapingByref | ( | VarDecl * | VD,
|  | Sema & | S
| ) |  |
| static

Definition at line 1705 of file Sema.cpp.

References clang::Sema::canThrow(), clang::Sema::Context, clang::ActionResult< PtrTy, CompressInvalid >::getAs(), clang::Type::getAsCXXRecordDecl(), clang::Decl::getLocation(), clang::ValueDecl::getType(), clang::InitializedEntity::InitializeBlock(), clang::ActionResult< PtrTy, CompressInvalid >::isInvalid(), clang::Sema::MaybeCreateExprWithCleanups(), clang::Sema::PerformMoveOrCopyInitialization(), clang::Sema::PotentiallyEvaluated, clang::Sema::ResolveExceptionSpec(), clang::Result, clang::ASTContext::setBlockVarCopyInit(), and clang::VK_LValue.

Referenced by markEscapingByrefs().

## ◆ checkUndefinedButUsed()

static void checkUndefinedButUsed | ( | Sema & | S | ) |
| static

checkUndefinedButUsed - Check for undefined objects with internal linkage or that are inline.

Definition at line 736 of file Sema.cpp.

Referenced by clang::Sema::ActOnEndOfTranslationUnit().

## ◆ emitCallStackNotes()

static void emitCallStackNotes | ( | Sema & | S,
|  | FunctionDecl * | FD
| ) |  |
| static

Definition at line 1437 of file Sema.cpp.

Referenced by clang::Sema::DeviceDiagBuilder::~DeviceDiagBuilder().

## ◆ emitDeferredDiags()

static void emitDeferredDiags | ( | Sema & | S,
|  | FunctionDecl * | FD,
|  | bool | ShowCallStack
| ) |  |
| static

Definition at line 1451 of file Sema.cpp.

Referenced by clang::Sema::markKnownEmitted().

## ◆ IsCallableWithAppend()

static bool IsCallableWithAppend | ( | Expr * | E | ) |
| static

Determine whether the given expression can be called by just putting parentheses after it.

Notably, expressions with unary operators can't be because the unary operator will start parsing outside the call.

Definition at line 2127 of file Sema.cpp.

References clang::Expr::IgnoreImplicit().

Referenced by clang::Sema::tryToRecoverWithCall().

## ◆ IsCPUDispatchCPUSpecificMultiVersion()

static bool IsCPUDispatchCPUSpecificMultiVersion | ( | const Expr * | E | ) |
| static

Definition at line 2135 of file Sema.cpp.

Referenced by clang::Sema::tryToRecoverWithCall().

## ◆ isFunctionOrVarDeclExternC()

static bool isFunctionOrVarDeclExternC | ( | NamedDecl * | ND | ) |
| static

Definition at line 664 of file Sema.cpp.

References isExternC().

Referenced by clang::Sema::isExternalWithNoLinkageType().

## ◆ IsRecordFullyDefined()

static bool IsRecordFullyDefined | ( | const CXXRecordDecl * | RD,
|  | RecordCompleteMap & | RecordsComplete,
|  | RecordCompleteMap & | MNCComplete
| ) |  |
| static

Returns true, if the given CXXRecordDecl is fully defined in this translation unit, i.e.

all methods are defined or pure virtual and all friends, friend functions and nested classes are fully defined in this translation unit.

Should only be called from ActOnEndOfTranslationUnit so that all definitions are actually read.

Definition at line 846 of file Sema.cpp.

References clang::CXXRecordDecl::friend_begin(), clang::CXXRecordDecl::friend_end(), and MethodsAndNestedClassesComplete().

## ◆ markEscapingByrefs()

static void markEscapingByrefs | ( | const FunctionScopeInfo & | FSI,
|  | Sema & | S
| ) |  |
| static

Definition at line 1730 of file Sema.cpp.

References clang::sema::FunctionScopeInfo::Blocks, clang::sema::FunctionScopeInfo::ByrefBlockVars, clang::BlockDecl::captures(), checkEscapingByref(), clang::Sema::checkNonTrivialCUnion(), clang::BlockDecl::doesNotEscape(), clang::BlockDecl::getCaretLocation(), clang::ValueDecl::getType(), clang::Decl::hasAttr(), clang::QualType::hasNonTrivialToPrimitiveCopyCUnion(), clang::QualType::hasNonTrivialToPrimitiveDestructCUnion(), clang::VarDecl::isEscapingByref(), clang::Type::isStructureOrClassType(), clang::Sema::NTCUC_BlockCapture, clang::Sema::NTCUK_Copy, clang::Sema::NTCUK_Destruct, and clang::VarDecl::setEscapingByref().

Referenced by clang::Sema::PopFunctionScopeInfo().

## ◆ MethodsAndNestedClassesComplete()

static bool MethodsAndNestedClassesComplete | ( | const CXXRecordDecl * | RD,
|  | RecordCompleteMap & | MNCComplete
| ) |  |
| static

Returns true, if all methods and nested classes of the given CXXRecordDecl are defined in this translation unit.

Should only be called from ActOnEndOfTranslationUnit so that all definitions are actually read.

Definition at line 804 of file Sema.cpp.

References clang::DeclContext::decls_begin(), clang::DeclContext::decls_end(), clang::if(), and clang::TagDecl::isCompleteDefinition().

Referenced by IsRecordFullyDefined().

## ◆ noteOverloads()

static void noteOverloads | ( | Sema & | S,
|  | const UnresolvedSetImpl & | Overloads,
|  | const SourceLocation | FinalNoteLoc
| ) |  |
| static

Give notes for a set of overloads.

A companion to tryExprAsCall. In cases when the name that the programmer wrote was an overloaded function, we may be able to make some guesses about plausible overloads based on their return types; such guesses can be handed off to this method to be emitted as notes.

Parameters

  Overloads | - The overloads to note.
  FinalNoteLoc | - If we've suppressed printing some overloads due to -fshow-overloads=best, this is the location to attach to the note about too many candidates. Typically this will be the location of the original ill-formed expression.

Definition at line 2077 of file Sema.cpp.

References clang::UnresolvedSetImpl::begin(), clang::Sema::Diag(), clang::Sema::Diags, clang::UnresolvedSetImpl::end(), clang::Decl::getAsFunction(), clang::Decl::getLocation(), clang::DiagnosticsEngine::getShowOverloads(), clang::NamedDecl::getUnderlyingDecl(), and clang::Ovl_Best.

Referenced by notePlausibleOverloads().

## ◆ notePlausibleOverloads()

static void notePlausibleOverloads | ( | Sema & | S,
|  | SourceLocation | Loc,
|  | const UnresolvedSetImpl & | Overloads,
|  | bool(*)(QualType) | IsPlausibleResult
| ) |  |
| static

Definition at line 2106 of file Sema.cpp.

References clang::UnresolvedSetImpl::addDecl(), clang::UnresolvedSetImpl::begin(), clang::UnresolvedSetImpl::end(), clang::FunctionDecl::getReturnType(), and noteOverloads().

Referenced by clang::Sema::tryToRecoverWithCall().

## ◆ ShouldRemoveFromUnused()

static bool ShouldRemoveFromUnused | ( | Sema * | SemaRef,
|  | const DeclaratorDecl * | D
| ) |  |
| static

Used to prune the decls of Sema's UnusedFileScopedDecls vector.

Definition at line 603 of file Sema.cpp.

References clang::Sema::Context, clang::VarDecl::getDefinition(), clang::Redeclarable< decl_type >::getMostRecentDecl(), clang::NamedDecl::getMostRecentDecl(), clang::NamedDecl::isExternallyVisible(), clang::Decl::isUsed(), and clang::Sema::ShouldWarnIfUnusedFileScopedDecl().

Referenced by clang::Sema::ActOnEndOfTranslationUnit().