clang 20.0.0git
|
#include "UsedDeclVisitor.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTDiagnostic.h"
#include "clang/AST/Decl.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/AST/TypeOrdering.h"
#include "clang/Basic/DarwinSDKInfo.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/PartialDiagnostic.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/Stack.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/CXXFieldCollector.h"
#include "clang/Sema/DelayedDiagnostic.h"
#include "clang/Sema/EnterExpressionEvaluationContext.h"
#include "clang/Sema/ExternalSemaSource.h"
#include "clang/Sema/Initialization.h"
#include "clang/Sema/MultiplexExternalSemaSource.h"
#include "clang/Sema/ObjCMethodList.h"
#include "clang/Sema/RISCVIntrinsicManager.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/ScopeInfo.h"
#include "clang/Sema/SemaAMDGPU.h"
#include "clang/Sema/SemaARM.h"
#include "clang/Sema/SemaAVR.h"
#include "clang/Sema/SemaBPF.h"
#include "clang/Sema/SemaCUDA.h"
#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaConsumer.h"
#include "clang/Sema/SemaHLSL.h"
#include "clang/Sema/SemaHexagon.h"
#include "clang/Sema/SemaInternal.h"
#include "clang/Sema/SemaLoongArch.h"
#include "clang/Sema/SemaM68k.h"
#include "clang/Sema/SemaMIPS.h"
#include "clang/Sema/SemaMSP430.h"
#include "clang/Sema/SemaNVPTX.h"
#include "clang/Sema/SemaObjC.h"
#include "clang/Sema/SemaOpenACC.h"
#include "clang/Sema/SemaOpenCL.h"
#include "clang/Sema/SemaOpenMP.h"
#include "clang/Sema/SemaPPC.h"
#include "clang/Sema/SemaPseudoObject.h"
#include "clang/Sema/SemaRISCV.h"
#include "clang/Sema/SemaSYCL.h"
#include "clang/Sema/SemaSwift.h"
#include "clang/Sema/SemaSystemZ.h"
#include "clang/Sema/SemaWasm.h"
#include "clang/Sema/SemaX86.h"
#include "clang/Sema/TemplateDeduction.h"
#include "clang/Sema/TemplateInstCallback.h"
#include "clang/Sema/TypoCorrection.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/TimeProfiler.h"
#include <optional>
#include "clang/Basic/OpenCLExtensionTypes.def"
#include "clang/Basic/AArch64SVEACLETypes.def"
#include "clang/Basic/PPCTypes.def"
#include "clang/Basic/RISCVVTypes.def"
#include "clang/Basic/WebAssemblyReferenceTypes.def"
#include "clang/Basic/AMDGPUTypes.def"
Go to the source code of this file.
Classes | |
class | clang::sema::SemaPPCallbacks |
Namespaces | |
namespace | clang |
The JSON file list parser is used to communicate input to InstallAPI. | |
namespace | clang::sema |
Macros | |
#define | EXT_OPAQUE_TYPE(ExtType, Id, Ext) |
#define | SVE_TYPE(Name, Id, SingletonId) addImplicitTypedef(Name, Context.SingletonId); |
#define | PPC_VECTOR_MMA_TYPE(Name, Id, Size) addImplicitTypedef(#Name, Context.Id##Ty); |
#define | PPC_VECTOR_VSX_TYPE(Name, Id, Size) addImplicitTypedef(#Name, Context.Id##Ty); |
#define | RVV_TYPE(Name, Id, SingletonId) addImplicitTypedef(Name, Context.SingletonId); |
#define | WASM_TYPE(Name, Id, SingletonId) addImplicitTypedef(Name, Context.SingletonId); |
#define | AMDGPU_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. | |
static bool | isFunctionOrVarDeclExternC (const NamedDecl *ND) |
static void | checkUndefinedButUsed (Sema &S) |
checkUndefinedButUsed - Check for undefined objects with internal linkage or that are inline. | |
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. | |
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. | |
static void | emitCallStackNotes (Sema &S, const FunctionDecl *FD) |
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. | |
static void | notePlausibleOverloads (Sema &S, SourceLocation Loc, const UnresolvedSetImpl &Overloads, bool(*IsPlausibleResult)(QualType)) |
static bool | IsCallableWithAppend (const Expr *E) |
Determine whether the given expression can be called by just putting parentheses after it. | |
static bool | IsCPUDispatchCPUSpecificMultiVersion (const Expr *E) |
#define AMDGPU_TYPE | ( | Name, | |
Id, | |||
SingletonId | |||
) | addImplicitTypedef(Name, Context.SingletonId); |
#define EXT_OPAQUE_TYPE | ( | ExtType, | |
Id, | |||
Ext | |||
) |
#define PPC_VECTOR_MMA_TYPE | ( | Name, | |
Id, | |||
Size | |||
) | addImplicitTypedef(#Name, Context.Id##Ty); |
#define PPC_VECTOR_VSX_TYPE | ( | Name, | |
Id, | |||
Size | |||
) | addImplicitTypedef(#Name, Context.Id##Ty); |
#define RVV_TYPE | ( | Name, | |
Id, | |||
SingletonId | |||
) | addImplicitTypedef(Name, Context.SingletonId); |
#define SVE_TYPE | ( | Name, | |
Id, | |||
SingletonId | |||
) | addImplicitTypedef(Name, Context.SingletonId); |
#define WASM_TYPE | ( | Name, | |
Id, | |||
SingletonId | |||
) | addImplicitTypedef(Name, Context.SingletonId); |
typedef llvm::DenseMap<const CXXRecordDecl*, bool> RecordCompleteMap |
Definition at line 2223 of file Sema.cpp.
References clang::Sema::canThrow(), clang::Sema::Context, clang::ImplicitCastExpr::Create(), E, clang::Type::getAsCXXRecordDecl(), clang::Sema::getLangOpts(), clang::Decl::getLocation(), clang::ValueDecl::getType(), clang::Init, clang::InitializedEntity::InitializeBlock(), Loc, clang::Sema::MaybeCreateExprWithCleanups(), clang::Sema::NamedReturnInfo::MoveEligible, clang::Sema::PerformCopyInitialization(), clang::Sema::PerformMoveOrCopyInitialization(), clang::Sema::PotentiallyEvaluated, clang::Sema::ResolveExceptionSpec(), clang::Result, clang::ASTContext::setBlockVarCopyInit(), clang::T, clang::VK_LValue, and clang::VK_XValue.
Referenced by markEscapingByrefs().
|
static |
checkUndefinedButUsed - Check for undefined objects with internal linkage or that are inline.
Definition at line 935 of file Sema.cpp.
References clang::SemaBase::Diag(), clang::Func, clang::Decl::getAttr(), clang::Sema::getLangOpts(), clang::Type::getLinkage(), clang::Decl::getLocation(), clang::ValueDecl::getType(), clang::Sema::getUndefinedButUsed(), clang::NamedDecl::isExternallyVisible(), clang::isExternallyVisible(), clang::Sema::isExternalWithNoLinkageType(), clang::SourceLocation::isValid(), and clang::Sema::UndefinedButUsed.
Referenced by clang::Sema::ActOnEndOfTranslationUnit().
|
static |
Definition at line 1708 of file Sema.cpp.
References clang::Sema::CUDA(), clang::SemaCUDA::DeviceKnownEmittedFns, clang::Sema::Diags, clang::DiagnosticsEngine::hasFatalErrorOccurred(), and clang::DiagnosticsEngine::Report().
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 2650 of file Sema.cpp.
References E, and clang::Expr::IgnoreImplicit().
Referenced by clang::Sema::tryToRecoverWithCall().
Definition at line 2658 of file Sema.cpp.
References E, clang::FunctionDecl::isCPUDispatchMultiVersion(), and clang::FunctionDecl::isCPUSpecificMultiVersion().
Referenced by clang::Sema::tryToRecoverWithCall().
Definition at line 863 of file Sema.cpp.
Referenced by clang::Sema::isExternalWithNoLinkageType().
|
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 1057 of file Sema.cpp.
References clang::Complete, E, clang::CXXRecordDecl::friend_begin(), clang::CXXRecordDecl::friend_end(), and MethodsAndNestedClassesComplete().
Referenced by clang::Sema::ActOnEndOfTranslationUnit().
|
static |
Definition at line 2257 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().
|
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 1015 of file Sema.cpp.
References clang::Complete, clang::DeclContext::decls_begin(), clang::DeclContext::decls_end(), E, clang::TagDecl::isCompleteDefinition(), and MethodsAndNestedClassesComplete().
Referenced by IsRecordFullyDefined(), and MethodsAndNestedClassesComplete().
|
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.
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 2597 of file Sema.cpp.
References clang::UnresolvedSetImpl::begin(), clang::SemaBase::Diag(), clang::Sema::Diags, clang::UnresolvedSetImpl::end(), clang::Decl::getAttr(), clang::DiagnosticsEngine::getNumOverloadCandidatesToShow(), clang::Decl::hasAttr(), clang::FunctionDecl::isMultiVersion(), and clang::DiagnosticsEngine::overloadCandidatesShown().
Referenced by notePlausibleOverloads().
|
static |
Definition at line 2629 of file Sema.cpp.
References clang::UnresolvedSetImpl::addDecl(), clang::UnresolvedSetImpl::begin(), clang::UnresolvedSetImpl::end(), Loc, and noteOverloads().
Referenced by clang::Sema::tryToRecoverWithCall().
|
static |
Used to prune the decls of Sema's UnusedFileScopedDecls vector.
Definition at line 802 of file Sema.cpp.
References clang::Sema::Context, D, clang::VarDecl::getDefinition(), clang::Decl::getMostRecentDecl(), clang::Redeclarable< decl_type >::getMostRecentDecl(), clang::Decl::isUsed(), ShouldRemoveFromUnused(), and clang::Sema::ShouldWarnIfUnusedFileScopedDecl().
Referenced by clang::Sema::ActOnEndOfTranslationUnit(), and ShouldRemoveFromUnused().