Changeset View
Changeset View
Standalone View
Standalone View
clang/include/clang/Sema/Sema.h
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 6,935 Lines • ▼ Show 20 Lines | private: | ||||
/// Introduce the instantiated function parameters into the local | /// Introduce the instantiated function parameters into the local | ||||
/// instantiation scope, and set the parameter names to those used | /// instantiation scope, and set the parameter names to those used | ||||
/// in the template. | /// in the template. | ||||
bool addInstantiatedParametersToScope( | bool addInstantiatedParametersToScope( | ||||
FunctionDecl *Function, const FunctionDecl *PatternDecl, | FunctionDecl *Function, const FunctionDecl *PatternDecl, | ||||
LocalInstantiationScope &Scope, | LocalInstantiationScope &Scope, | ||||
const MultiLevelTemplateArgumentList &TemplateArgs); | const MultiLevelTemplateArgumentList &TemplateArgs); | ||||
llvm::Optional<MultiLevelTemplateArgumentList> | |||||
SetupConstraintCheckingTemplateArgumentsAndScope( | |||||
FunctionDecl *FD, llvm::Optional<ArrayRef<TemplateArgument>> TemplateArgs, | |||||
LocalInstantiationScope &Scope); | |||||
// Keep track of whether we are evaluating a constraint. | |||||
unsigned ConstraintEvaluationDepth = 0; | |||||
Lint: Pre-merge checks: clang-format: please reformat the code
```
-
``` | |||||
class ConstraintEvalRAII { | |||||
Sema &S; | |||||
Lint: Pre-merge checks clang-format: please reformat the code + Lint: Pre-merge checks: clang-format: please reformat the code
```
+
``` | |||||
public: | public: | ||||
ConstraintEvalRAII(Sema &S) : S(S) { ++S.ConstraintEvaluationDepth; } | |||||
~ConstraintEvalRAII() { --S.ConstraintEvaluationDepth; } | |||||
}; | |||||
public: | |||||
bool IsEvaluatingAConstraint() { | |||||
Lint: Pre-merge checks clang-format: please reformat the code - bool IsEvaluatingAConstraint() { - return ConstraintEvaluationDepth > 0; - } + bool IsEvaluatingAConstraint() { return ConstraintEvaluationDepth > 0; } Lint: Pre-merge checks: clang-format: please reformat the code
```
- bool IsEvaluatingAConstraint() {
- return… | |||||
return ConstraintEvaluationDepth > 0; | |||||
} | |||||
const NormalizedConstraint * | const NormalizedConstraint * | ||||
getNormalizedAssociatedConstraints( | getNormalizedAssociatedConstraints( | ||||
NamedDecl *ConstrainedDecl, ArrayRef<const Expr *> AssociatedConstraints); | NamedDecl *ConstrainedDecl, ArrayRef<const Expr *> AssociatedConstraints); | ||||
/// \brief Check whether the given declaration's associated constraints are | /// \brief Check whether the given declaration's associated constraints are | ||||
/// at least as constrained than another declaration's according to the | /// at least as constrained than another declaration's according to the | ||||
/// partial ordering of constraints. | /// partial ordering of constraints. | ||||
/// | /// | ||||
Show All 13 Lines | bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(NamedDecl *D1, | ||||
ArrayRef<const Expr *> AC1, NamedDecl *D2, ArrayRef<const Expr *> AC2); | ArrayRef<const Expr *> AC1, NamedDecl *D2, ArrayRef<const Expr *> AC2); | ||||
/// \brief Check whether the given list of constraint expressions are | /// \brief Check whether the given list of constraint expressions are | ||||
/// satisfied (as if in a 'conjunction') given template arguments. | /// satisfied (as if in a 'conjunction') given template arguments. | ||||
/// \param Template the template-like entity that triggered the constraints | /// \param Template the template-like entity that triggered the constraints | ||||
/// check (either a concept or a constrained entity). | /// check (either a concept or a constrained entity). | ||||
/// \param ConstraintExprs a list of constraint expressions, treated as if | /// \param ConstraintExprs a list of constraint expressions, treated as if | ||||
/// they were 'AND'ed together. | /// they were 'AND'ed together. | ||||
/// \param TemplateArgs the list of template arguments to substitute into the | /// \param TemplateArgs the list of template arguments to substitute into the | ||||
/// constraint expression. | /// constraint expression, which is multi-level since we have to substitute | ||||
/// ALL levels for the purposes of checking. | |||||
Lint: Pre-merge checks clang-format: please reformat the code - /// ALL levels for the purposes of checking. + /// ALL levels for the purposes of checking. Lint: Pre-merge checks: clang-format: please reformat the code
```
- /// ALL levels for the purposes of checking.
+… | |||||
/// \param TemplateIDRange The source range of the template id that | /// \param TemplateIDRange The source range of the template id that | ||||
Now the comment is not precise. ChuanqiXu: Now the comment is not precise. | |||||
/// caused the constraints check. | /// caused the constraints check. | ||||
/// \param Satisfaction if true is returned, will contain details of the | /// \param Satisfaction if true is returned, will contain details of the | ||||
/// satisfaction, with enough information to diagnose an unsatisfied | /// satisfaction, with enough information to diagnose an unsatisfied | ||||
/// expression. | /// expression. | ||||
/// \returns true if an error occurred and satisfaction could not be checked, | /// \returns true if an error occurred and satisfaction could not be checked, | ||||
/// false otherwise. | /// false otherwise. | ||||
bool CheckConstraintSatisfaction( | bool CheckConstraintSatisfaction( | ||||
const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs, | const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs, | ||||
ArrayRef<TemplateArgument> TemplateArgs, | const MultiLevelTemplateArgumentList &TemplateArgList, | ||||
SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction) { | |||||
llvm::SmallVector<Expr*, 4> Converted; | |||||
Lint: Pre-merge checks clang-format: please reformat the code - llvm::SmallVector<Expr*, 4> Converted; + llvm::SmallVector<Expr *, 4> Converted; Lint: Pre-merge checks: clang-format: please reformat the code
```
- llvm::SmallVector<Expr*, 4> Converted;
+… | |||||
return CheckConstraintSatisfaction(Template, ConstraintExprs, Converted, | |||||
TemplateArgList, TemplateIDRange, | |||||
Satisfaction); | |||||
} | |||||
bool CheckConstraintSatisfaction( | |||||
I think this one need comment too. What's the difference with the above one? ChuanqiXu: I think this one need comment too. What's the difference with the above one? | |||||
Thanks! I'll comment on that. The difference is the 'out' parameter of 'ConvertedConstraints', but I'll put details in the comment. erichkeane: Thanks! I'll comment on that. The difference is the 'out' parameter of 'ConvertedConstraints'… | |||||
const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs, | |||||
llvm::SmallVectorImpl<Expr *> &ConvertedConstraints, | |||||
const MultiLevelTemplateArgumentList &TemplateArgList, | |||||
SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction); | SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction); | ||||
/// \brief Check whether the given non-dependent constraint expression is | /// \brief Check whether the given non-dependent constraint expression is | ||||
/// satisfied. Returns false and updates Satisfaction with the satisfaction | /// satisfied. Returns false and updates Satisfaction with the satisfaction | ||||
/// verdict if successful, emits a diagnostic and returns true if an error | /// verdict if successful, emits a diagnostic and returns true if an error | ||||
/// occurred and satisfaction could not be determined. | /// occurred and satisfaction could not be determined. | ||||
/// | /// | ||||
/// \returns true if an error occurred, false otherwise. | /// \returns true if an error occurred, false otherwise. | ||||
Show All 19 Lines | public: | ||||
/// | /// | ||||
/// \param TemplateArgs The converted, canonicalized template arguments. | /// \param TemplateArgs The converted, canonicalized template arguments. | ||||
/// | /// | ||||
/// \param TemplateIDRange The source range of the template id that | /// \param TemplateIDRange The source range of the template id that | ||||
/// caused the constraints check. | /// caused the constraints check. | ||||
/// | /// | ||||
/// \returns true if the constrains are not satisfied or could not be checked | /// \returns true if the constrains are not satisfied or could not be checked | ||||
/// for satisfaction, false if the constraints are satisfied. | /// for satisfaction, false if the constraints are satisfied. | ||||
bool EnsureTemplateArgumentListConstraints(TemplateDecl *Template, | bool EnsureTemplateArgumentListConstraints( | ||||
ArrayRef<TemplateArgument> TemplateArgs, | TemplateDecl *Template, MultiLevelTemplateArgumentList TemplateArgs, | ||||
SourceRange TemplateIDRange); | SourceRange TemplateIDRange); | ||||
/// \brief Emit diagnostics explaining why a constraint expression was deemed | /// \brief Emit diagnostics explaining why a constraint expression was deemed | ||||
/// unsatisfied. | /// unsatisfied. | ||||
/// \param First whether this is the first time an unsatisfied constraint is | /// \param First whether this is the first time an unsatisfied constraint is | ||||
/// diagnosed for this error. | /// diagnosed for this error. | ||||
void | void | ||||
DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, | DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, | ||||
bool First = true); | bool First = true); | ||||
▲ Show 20 Lines • Show All 1,716 Lines • ▼ Show 20 Lines | static void MarkDeducedTemplateParameters(ASTContext &Ctx, | ||||
llvm::SmallBitVector &Deduced); | llvm::SmallBitVector &Deduced); | ||||
//===--------------------------------------------------------------------===// | //===--------------------------------------------------------------------===// | ||||
// C++ Template Instantiation | // C++ Template Instantiation | ||||
// | // | ||||
MultiLevelTemplateArgumentList getTemplateInstantiationArgs( | MultiLevelTemplateArgumentList getTemplateInstantiationArgs( | ||||
const NamedDecl *D, const TemplateArgumentList *Innermost = nullptr, | const NamedDecl *D, const TemplateArgumentList *Innermost = nullptr, | ||||
bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr); | bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr, | ||||
bool LookBeyondLambda = false, bool IncludeContainingStruct = false); | |||||
/// A context in which code is being synthesized (where a source location | /// A context in which code is being synthesized (where a source location | ||||
/// alone is not sufficient to identify the context). This covers template | /// alone is not sufficient to identify the context). This covers template | ||||
/// instantiation and various forms of implicitly-generated functions. | /// instantiation and various forms of implicitly-generated functions. | ||||
struct CodeSynthesisContext { | struct CodeSynthesisContext { | ||||
/// The kind of template instantiation we are performing | /// The kind of template instantiation we are performing | ||||
enum SynthesisKind { | enum SynthesisKind { | ||||
/// We are instantiating a template declaration. The entity is | /// We are instantiating a template declaration. The entity is | ||||
▲ Show 20 Lines • Show All 704 Lines • ▼ Show 20 Lines | |||||
bool SubstParmTypes(SourceLocation Loc, ArrayRef<ParmVarDecl *> Params, | bool SubstParmTypes(SourceLocation Loc, ArrayRef<ParmVarDecl *> Params, | ||||
const FunctionProtoType::ExtParameterInfo *ExtParamInfos, | const FunctionProtoType::ExtParameterInfo *ExtParamInfos, | ||||
const MultiLevelTemplateArgumentList &TemplateArgs, | const MultiLevelTemplateArgumentList &TemplateArgs, | ||||
SmallVectorImpl<QualType> &ParamTypes, | SmallVectorImpl<QualType> &ParamTypes, | ||||
SmallVectorImpl<ParmVarDecl *> *OutParams, | SmallVectorImpl<ParmVarDecl *> *OutParams, | ||||
ExtParameterInfoBuilder &ParamInfos); | ExtParameterInfoBuilder &ParamInfos); | ||||
ExprResult SubstExpr(Expr *E, | ExprResult SubstExpr(Expr *E, | ||||
const MultiLevelTemplateArgumentList &TemplateArgs); | const MultiLevelTemplateArgumentList &TemplateArgs); | ||||
// Unlike the above, this evaluates constraints, which should only happen at | |||||
// 'constraint checking' time. | |||||
ExprResult | |||||
SubstConstraintExpr(Expr *E, | |||||
const MultiLevelTemplateArgumentList &TemplateArgs); | |||||
/// Substitute the given template arguments into a list of | /// Substitute the given template arguments into a list of | ||||
/// expressions, expanding pack expansions if required. | /// expressions, expanding pack expansions if required. | ||||
/// | /// | ||||
/// \param Exprs The list of expressions to substitute into. | /// \param Exprs The list of expressions to substitute into. | ||||
/// | /// | ||||
/// \param IsCall Whether this is some form of call, in which case | /// \param IsCall Whether this is some form of call, in which case | ||||
/// default arguments will be dropped. | /// default arguments will be dropped. | ||||
▲ Show 20 Lines • Show All 3,844 Lines • Show Last 20 Lines |
clang-format: please reformat the code