diff options
Diffstat (limited to 'include/clang/Sema')
| -rw-r--r-- | include/clang/Sema/CodeCompleteConsumer.h | 70 | ||||
| -rw-r--r-- | include/clang/Sema/CodeCompleteOptions.h | 3 | ||||
| -rw-r--r-- | include/clang/Sema/DeclSpec.h | 89 | ||||
| -rw-r--r-- | include/clang/Sema/Initialization.h | 25 | ||||
| -rw-r--r-- | include/clang/Sema/Lookup.h | 6 | ||||
| -rw-r--r-- | include/clang/Sema/LoopHint.h | 45 | ||||
| -rw-r--r-- | include/clang/Sema/Overload.h | 13 | ||||
| -rw-r--r-- | include/clang/Sema/ParsedAttr.h | 228 | ||||
| -rw-r--r-- | include/clang/Sema/Scope.h | 1 | ||||
| -rw-r--r-- | include/clang/Sema/ScopeInfo.h | 17 | ||||
| -rw-r--r-- | include/clang/Sema/Sema.h | 356 | ||||
| -rw-r--r-- | include/clang/Sema/SemaDiagnostic.h | 15 |
12 files changed, 543 insertions, 325 deletions
diff --git a/include/clang/Sema/CodeCompleteConsumer.h b/include/clang/Sema/CodeCompleteConsumer.h index ede3ddf91993..5e46a84128d5 100644 --- a/include/clang/Sema/CodeCompleteConsumer.h +++ b/include/clang/Sema/CodeCompleteConsumer.h @@ -17,6 +17,7 @@ #include "clang-c/Index.h" #include "clang/AST/Type.h" #include "clang/Basic/LLVM.h" +#include "clang/Lex/MacroInfo.h" #include "clang/Sema/CodeCompleteOptions.h" #include "clang/Sema/DeclSpec.h" #include "llvm/ADT/ArrayRef.h" @@ -271,11 +272,15 @@ public: CCC_Type, /// Code completion occurred where a new name is expected. - CCC_Name, + CCC_NewName, - /// Code completion occurred where a new name is expected and a - /// qualified name is permissible. - CCC_PotentiallyQualifiedName, + /// Code completion occurred where both a new name and an existing symbol is + /// permissible. + CCC_SymbolOrNewName, + + /// Code completion occurred where an existing name(such as type, function + /// or variable) is expected. + CCC_Symbol, /// Code completion occurred where an macro is being defined. CCC_MacroName, @@ -322,6 +327,9 @@ public: /// Code completion where an Objective-C category name is expected. CCC_ObjCCategoryName, + /// Code completion inside the filename part of a #include directive. + CCC_IncludedFile, + /// An unknown context, in which we are recovering from a parsing /// error and don't know which completions we should give. CCC_Recovery @@ -817,6 +825,9 @@ public: /// Whether this result is hidden by another name. bool Hidden : 1; + /// Whether this is a class member from base class. + bool InBaseClass : 1; + /// Whether this result was found via lookup into a base class. bool QualifierIsInformative : 1; @@ -843,6 +854,11 @@ public: /// corresponding `using decl::qualified::name;` nearby. const UsingShadowDecl *ShadowDecl = nullptr; + /// If the result is RK_Macro, this can store the information about the macro + /// definition. This should be set in most cases but can be missing when + /// the macro has been undefined. + const MacroInfo *MacroDefInfo = nullptr; + /// Build a result that refers to a declaration. CodeCompletionResult(const NamedDecl *Declaration, unsigned Priority, NestedNameSpecifier *Qualifier = nullptr, @@ -850,7 +866,7 @@ public: bool Accessible = true, std::vector<FixItHint> FixIts = std::vector<FixItHint>()) : Declaration(Declaration), Priority(Priority), Kind(RK_Declaration), - FixIts(std::move(FixIts)), Hidden(false), + FixIts(std::move(FixIts)), Hidden(false), InBaseClass(false), QualifierIsInformative(QualifierIsInformative), StartsNestedNameSpecifier(false), AllParametersAreInformative(false), DeclaringEntity(false), Qualifier(Qualifier) { @@ -861,35 +877,38 @@ public: /// Build a result that refers to a keyword or symbol. CodeCompletionResult(const char *Keyword, unsigned Priority = CCP_Keyword) : Keyword(Keyword), Priority(Priority), Kind(RK_Keyword), - CursorKind(CXCursor_NotImplemented), Hidden(false), + CursorKind(CXCursor_NotImplemented), Hidden(false), InBaseClass(false), QualifierIsInformative(false), StartsNestedNameSpecifier(false), AllParametersAreInformative(false), DeclaringEntity(false) {} /// Build a result that refers to a macro. CodeCompletionResult(const IdentifierInfo *Macro, + const MacroInfo *MI = nullptr, unsigned Priority = CCP_Macro) : Macro(Macro), Priority(Priority), Kind(RK_Macro), - CursorKind(CXCursor_MacroDefinition), Hidden(false), + CursorKind(CXCursor_MacroDefinition), Hidden(false), InBaseClass(false), QualifierIsInformative(false), StartsNestedNameSpecifier(false), - AllParametersAreInformative(false), DeclaringEntity(false) {} + AllParametersAreInformative(false), DeclaringEntity(false), + MacroDefInfo(MI) {} /// Build a result that refers to a pattern. - CodeCompletionResult(CodeCompletionString *Pattern, - unsigned Priority = CCP_CodePattern, - CXCursorKind CursorKind = CXCursor_NotImplemented, - CXAvailabilityKind Availability = CXAvailability_Available, - const NamedDecl *D = nullptr) + CodeCompletionResult( + CodeCompletionString *Pattern, unsigned Priority = CCP_CodePattern, + CXCursorKind CursorKind = CXCursor_NotImplemented, + CXAvailabilityKind Availability = CXAvailability_Available, + const NamedDecl *D = nullptr) : Declaration(D), Pattern(Pattern), Priority(Priority), Kind(RK_Pattern), CursorKind(CursorKind), Availability(Availability), Hidden(false), - QualifierIsInformative(false), StartsNestedNameSpecifier(false), - AllParametersAreInformative(false), DeclaringEntity(false) {} + InBaseClass(false), QualifierIsInformative(false), + StartsNestedNameSpecifier(false), AllParametersAreInformative(false), + DeclaringEntity(false) {} /// Build a result that refers to a pattern with an associated /// declaration. CodeCompletionResult(CodeCompletionString *Pattern, const NamedDecl *D, unsigned Priority) : Declaration(D), Pattern(Pattern), Priority(Priority), Kind(RK_Pattern), - Hidden(false), QualifierIsInformative(false), + Hidden(false), InBaseClass(false), QualifierIsInformative(false), StartsNestedNameSpecifier(false), AllParametersAreInformative(false), DeclaringEntity(false) { computeCursorKindAndAvailability(); @@ -935,6 +954,16 @@ public: CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo); + CodeCompletionString *createCodeCompletionStringForDecl( + Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, + bool IncludeBriefComments, const CodeCompletionContext &CCContext, + PrintingPolicy &Policy); + + CodeCompletionString *createCodeCompletionStringForOverride( + Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, + bool IncludeBriefComments, const CodeCompletionContext &CCContext, + PrintingPolicy &Policy); + /// Retrieve the name that should be used to order a result. /// /// If the name needs to be constructed as a string, that string will be @@ -1114,9 +1143,13 @@ public: /// \param Candidates an array of overload candidates. /// /// \param NumCandidates the number of overload candidates + /// + /// \param OpenParLoc location of the opening parenthesis of the argument + /// list. virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, - unsigned NumCandidates) {} + unsigned NumCandidates, + SourceLocation OpenParLoc) {} //@} /// Retrieve the allocator that will be used to allocate @@ -1166,7 +1199,8 @@ public: void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, - unsigned NumCandidates) override; + unsigned NumCandidates, + SourceLocation OpenParLoc) override; bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results) override; diff --git a/include/clang/Sema/CodeCompleteOptions.h b/include/clang/Sema/CodeCompleteOptions.h index 1d3bbb4e585d..26f7f9d19f8e 100644 --- a/include/clang/Sema/CodeCompleteOptions.h +++ b/include/clang/Sema/CodeCompleteOptions.h @@ -36,7 +36,8 @@ public: unsigned IncludeBriefComments : 1; /// Hint whether to load data from the external AST to provide full results. - /// If false, namespace-level declarations from the preamble may be omitted. + /// If false, namespace-level declarations and macros from the preamble may be + /// omitted. unsigned LoadExternal : 1; /// Include results after corrections (small fix-its), e.g. change '.' to '->' diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index 2e70203c6cc0..8d6f0bc9148b 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -505,8 +505,8 @@ public: const CXXScopeSpec &getTypeSpecScope() const { return TypeScope; } SourceRange getSourceRange() const LLVM_READONLY { return Range; } - SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); } - SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); } + SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); } + SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); } SourceLocation getTypeSpecWidthLoc() const { return TSWRange.getBegin(); } SourceRange getTypeSpecWidthRange() const { return TSWRange; } @@ -593,6 +593,18 @@ public: FS_noreturnLoc = SourceLocation(); } + /// This method calls the passed in handler on each CVRU qual being + /// set. + /// Handle - a handler to be invoked. + void forEachCVRUQualifier( + llvm::function_ref<void(TQ, StringRef, SourceLocation)> Handle); + + /// This method calls the passed in handler on each qual being + /// set. + /// Handle - a handler to be invoked. + void forEachQualifier( + llvm::function_ref<void(TQ, StringRef, SourceLocation)> Handle); + /// Return true if any type-specifier has been found. bool hasTypeSpecifier() const { return getTypeSpecType() != DeclSpec::TST_unspecified || @@ -683,6 +695,8 @@ public: ExprRep = Rep; } + bool SetTypeQual(TQ T, SourceLocation Loc); + bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const LangOptions &Lang); @@ -1120,8 +1134,8 @@ public: SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(StartLocation, EndLocation); } - SourceLocation getLocStart() const LLVM_READONLY { return StartLocation; } - SourceLocation getLocEnd() const LLVM_READONLY { return EndLocation; } + SourceLocation getBeginLoc() const LLVM_READONLY { return StartLocation; } + SourceLocation getEndLoc() const LLVM_READONLY { return EndLocation; } }; /// A set of tokens that has been cached for later parsing. @@ -1250,10 +1264,6 @@ struct DeclaratorChunk { /// Otherwise, it's an rvalue reference. unsigned RefQualifierIsLValueRef : 1; - /// The type qualifiers: const/volatile/restrict/__unaligned - /// The qualifier bitmask values are the same as in QualType. - unsigned TypeQuals : 4; - /// ExceptionSpecType - An ExceptionSpecificationType value. unsigned ExceptionSpecType : 4; @@ -1287,21 +1297,6 @@ struct DeclaratorChunk { /// If this is an invalid location, there is no ref-qualifier. unsigned RefQualifierLoc; - /// The location of the const-qualifier, if any. - /// - /// If this is an invalid location, there is no const-qualifier. - unsigned ConstQualifierLoc; - - /// The location of the volatile-qualifier, if any. - /// - /// If this is an invalid location, there is no volatile-qualifier. - unsigned VolatileQualifierLoc; - - /// The location of the restrict-qualifier, if any. - /// - /// If this is an invalid location, there is no restrict-qualifier. - unsigned RestrictQualifierLoc; - /// The location of the 'mutable' qualifer in a lambda-declarator, if /// any. unsigned MutableLoc; @@ -1317,6 +1312,12 @@ struct DeclaratorChunk { /// there are no parameters specified. ParamInfo *Params; + /// DeclSpec for the function with the qualifier related info. + DeclSpec *MethodQualifiers; + + /// AtttibuteFactory for the MethodQualifiers. + AttributeFactory *QualAttrFactory; + union { /// Pointer to a new[]'d array of TypeAndRange objects that /// contain the types in the function's dynamic exception specification @@ -1356,6 +1357,8 @@ struct DeclaratorChunk { void destroy() { freeParams(); + delete QualAttrFactory; + delete MethodQualifiers; switch (getExceptionSpecType()) { default: break; @@ -1372,6 +1375,14 @@ struct DeclaratorChunk { } } + DeclSpec &getOrCreateMethodQualifiers() { + if (!MethodQualifiers) { + QualAttrFactory = new AttributeFactory(); + MethodQualifiers = new DeclSpec(*QualAttrFactory); + } + return *MethodQualifiers; + } + /// isKNRPrototype - Return true if this is a K&R style identifier list, /// like "void foo(a,b,c)". In a function definition, this will be followed /// by the parameter type definitions. @@ -1406,19 +1417,22 @@ struct DeclaratorChunk { return SourceLocation::getFromRawEncoding(RefQualifierLoc); } - /// Retrieve the location of the 'const' qualifier, if any. + /// Retrieve the location of the 'const' qualifier. SourceLocation getConstQualifierLoc() const { - return SourceLocation::getFromRawEncoding(ConstQualifierLoc); + assert(MethodQualifiers); + return MethodQualifiers->getConstSpecLoc(); } - /// Retrieve the location of the 'volatile' qualifier, if any. + /// Retrieve the location of the 'volatile' qualifier. SourceLocation getVolatileQualifierLoc() const { - return SourceLocation::getFromRawEncoding(VolatileQualifierLoc); + assert(MethodQualifiers); + return MethodQualifiers->getVolatileSpecLoc(); } - /// Retrieve the location of the 'restrict' qualifier, if any. + /// Retrieve the location of the 'restrict' qualifier. SourceLocation getRestrictQualifierLoc() const { - return SourceLocation::getFromRawEncoding(RestrictQualifierLoc); + assert(MethodQualifiers); + return MethodQualifiers->getRestrictSpecLoc(); } /// Retrieve the location of the 'mutable' qualifier, if any. @@ -1434,6 +1448,12 @@ struct DeclaratorChunk { /// qualifier. bool hasMutableQualifier() const { return getMutableLoc().isValid(); } + /// Determine whether this method has qualifiers. + bool hasMethodTypeQualifiers() const { + return MethodQualifiers && (MethodQualifiers->getTypeQualifiers() || + MethodQualifiers->getAttributes().size()); + } + /// Get the type of exception specification this function has. ExceptionSpecificationType getExceptionSpecType() const { return static_cast<ExceptionSpecificationType>(ExceptionSpecType); @@ -1574,12 +1594,8 @@ struct DeclaratorChunk { ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, - unsigned TypeQuals, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, - SourceLocation ConstQualifierLoc, - SourceLocation VolatileQualifierLoc, - SourceLocation RestrictQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, @@ -1593,7 +1609,8 @@ struct DeclaratorChunk { SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType = - TypeResult()); + TypeResult(), + DeclSpec *MethodQualifiers = nullptr); /// Return a DeclaratorChunk for a block. static DeclaratorChunk getBlockPointer(unsigned TypeQuals, @@ -1870,8 +1887,8 @@ public: /// Get the source range that spans this declarator. SourceRange getSourceRange() const LLVM_READONLY { return Range; } - SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); } - SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); } + SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); } + SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); } void SetSourceRange(SourceRange R) { Range = R; } /// SetRangeBegin - Set the start of the source range to Loc, unless it's diff --git a/include/clang/Sema/Initialization.h b/include/clang/Sema/Initialization.h index 8582e971d0b6..3a2d6275650d 100644 --- a/include/clang/Sema/Initialization.h +++ b/include/clang/Sema/Initialization.h @@ -671,10 +671,11 @@ public: static InitializationKind CreateForInit(SourceLocation Loc, bool DirectInit, Expr *Init) { if (!Init) return CreateDefault(Loc); - if (!DirectInit) return CreateCopy(Loc, Init->getLocStart()); + if (!DirectInit) + return CreateCopy(Loc, Init->getBeginLoc()); if (isa<InitListExpr>(Init)) - return CreateDirectList(Loc, Init->getLocStart(), Init->getLocEnd()); - return CreateDirect(Loc, Init->getLocStart(), Init->getLocEnd()); + return CreateDirectList(Loc, Init->getBeginLoc(), Init->getEndLoc()); + return CreateDirect(Loc, Init->getBeginLoc(), Init->getEndLoc()); } /// Determine the initialization kind. @@ -892,11 +893,8 @@ public: /// Initialize an OpenCL sampler from an integer. SK_OCLSamplerInit, - /// Initialize queue_t from 0. - SK_OCLZeroQueue, - - /// Passing zero to a function where OpenCL event_t is expected. - SK_OCLZeroEvent + /// Initialize an opaque OpenCL type (event_t, queue_t, etc.) with zero + SK_OCLZeroOpaqueType }; /// A single step in the initialization sequence. @@ -1333,12 +1331,13 @@ public: /// constant. void AddOCLSamplerInitStep(QualType T); - /// Add a step to initialize an OpenCL event_t from a NULL - /// constant. - void AddOCLZeroEventStep(QualType T); + /// Add a step to initialzie an OpenCL opaque type (event_t, queue_t, etc.) + /// from a zero constant. + void AddOCLZeroOpaqueTypeStep(QualType T); - /// Add a step to initialize an OpenCL queue_t from 0. - void AddOCLZeroQueueStep(QualType T); + /// Add a step to initialize by zero types defined in the + /// cl_intel_device_side_avc_motion_estimation OpenCL extension + void AddOCLIntelSubgroupAVCZeroInitStep(QualType T); /// Add steps to unwrap a initializer list for a reference around a /// single element and rewrap it at the end. diff --git a/include/clang/Sema/Lookup.h b/include/clang/Sema/Lookup.h index e28b847f4ae5..4f7da851e232 100644 --- a/include/clang/Sema/Lookup.h +++ b/include/clang/Sema/Lookup.h @@ -540,7 +540,7 @@ public: } /// Clears out any current state. - void clear() { + LLVM_ATTRIBUTE_REINITIALIZES void clear() { ResultKind = NotFound; Decls.clear(); if (Paths) deletePaths(Paths); @@ -709,7 +709,9 @@ private: // Results. LookupResultKind ResultKind = NotFound; - AmbiguityKind Ambiguity; // ill-defined unless ambiguous + // ill-defined unless ambiguous. Still need to be initialized it will be + // copied/moved. + AmbiguityKind Ambiguity = {}; UnresolvedSet<8> Decls; CXXBasePaths *Paths = nullptr; CXXRecordDecl *NamingClass = nullptr; diff --git a/include/clang/Sema/LoopHint.h b/include/clang/Sema/LoopHint.h deleted file mode 100644 index 171435e69bc8..000000000000 --- a/include/clang/Sema/LoopHint.h +++ /dev/null @@ -1,45 +0,0 @@ -//===--- LoopHint.h - Types for LoopHint ------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_SEMA_LOOPHINT_H -#define LLVM_CLANG_SEMA_LOOPHINT_H - -#include "clang/Basic/IdentifierTable.h" -#include "clang/Basic/SourceLocation.h" -#include "clang/Sema/Ownership.h" -#include "clang/Sema/ParsedAttr.h" - -namespace clang { - -/// Loop optimization hint for loop and unroll pragmas. -struct LoopHint { - // Source range of the directive. - SourceRange Range; - // Identifier corresponding to the name of the pragma. "loop" for - // "#pragma clang loop" directives and "unroll" for "#pragma unroll" - // hints. - IdentifierLoc *PragmaNameLoc; - // Name of the loop hint. Examples: "unroll", "vectorize". In the - // "#pragma unroll" and "#pragma nounroll" cases, this is identical to - // PragmaNameLoc. - IdentifierLoc *OptionLoc; - // Identifier for the hint state argument. If null, then the state is - // default value such as for "#pragma unroll". - IdentifierLoc *StateLoc; - // Expression for the hint argument if it exists, null otherwise. - Expr *ValueExpr; - - LoopHint() - : PragmaNameLoc(nullptr), OptionLoc(nullptr), StateLoc(nullptr), - ValueExpr(nullptr) {} -}; - -} // end namespace clang - -#endif // LLVM_CLANG_SEMA_LOOPHINT_H diff --git a/include/clang/Sema/Overload.h b/include/clang/Sema/Overload.h index 6ded010ee8ed..96fd5892daae 100644 --- a/include/clang/Sema/Overload.h +++ b/include/clang/Sema/Overload.h @@ -755,12 +755,12 @@ class Sema; ConversionFixItGenerator Fix; /// Viable - True to indicate that this overload candidate is viable. - bool Viable; + bool Viable : 1; /// IsSurrogate - True to indicate that this candidate is a /// surrogate for a conversion to a function pointer or reference /// (C++ [over.call.object]). - bool IsSurrogate; + bool IsSurrogate : 1; /// IgnoreObjectArgument - True to indicate that the first /// argument's conversion, which for this function represents the @@ -769,7 +769,10 @@ class Sema; /// implicit object argument is just a placeholder) or a /// non-static member function when the call doesn't have an /// object argument. - bool IgnoreObjectArgument; + bool IgnoreObjectArgument : 1; + + /// True if the candidate was found using ADL. + CallExpr::ADLCallKind IsADLCandidate : 1; /// FailureKind - The reason why this candidate is not viable. /// Actually an OverloadFailureKind. @@ -823,6 +826,10 @@ class Sema; return Function->getNumParams(); return ExplicitCallArguments; } + + private: + friend class OverloadCandidateSet; + OverloadCandidate() : IsADLCandidate(CallExpr::NotADL) {} }; /// OverloadCandidateSet - A set of overload candidates, used in C++ diff --git a/include/clang/Sema/ParsedAttr.h b/include/clang/Sema/ParsedAttr.h index cfb91af78370..11202cb137b5 100644 --- a/include/clang/Sema/ParsedAttr.h +++ b/include/clang/Sema/ParsedAttr.h @@ -16,6 +16,7 @@ #define LLVM_CLANG_SEMA_ATTRIBUTELIST_H #include "clang/Basic/AttrSubjectMatchRules.h" +#include "clang/Basic/Diagnostic.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/TargetInfo.h" #include "clang/Sema/Ownership.h" @@ -54,8 +55,7 @@ struct AvailabilityChange { bool isValid() const { return !Version.empty(); } }; -namespace { - +namespace detail { enum AvailabilitySlot { IntroducedSlot, DeprecatedSlot, ObsoletedSlot, NumAvailabilitySlots }; @@ -77,6 +77,18 @@ struct AvailabilityData { } }; +struct TypeTagForDatatypeData { + ParsedType MatchingCType; + unsigned LayoutCompatible : 1; + unsigned MustBeNull : 1; +}; +struct PropertyData { + IdentifierInfo *GetterId, *SetterId; + + PropertyData(IdentifierInfo *getterId, IdentifierInfo *setterId) + : GetterId(getterId), SetterId(setterId) {} +}; + } // namespace /// Wraps an identifier and optional source location for the identifier. @@ -102,7 +114,27 @@ using ArgsVector = llvm::SmallVector<ArgsUnion, 12U>; /// 3: __attribute__(( format(printf, 1, 2) )). ParmName/Args/NumArgs all used. /// 4: __attribute__(( aligned(16) )). ParmName is unused, Args/Num used. /// -class ParsedAttr { // TODO: This should really be called ParsedAttribute +class ParsedAttr final + : private llvm::TrailingObjects< + ParsedAttr, ArgsUnion, detail::AvailabilityData, + detail::TypeTagForDatatypeData, ParsedType, detail::PropertyData> { + friend TrailingObjects; + + size_t numTrailingObjects(OverloadToken<ArgsUnion>) const { return NumArgs; } + size_t numTrailingObjects(OverloadToken<detail::AvailabilityData>) const { + return IsAvailability; + } + size_t + numTrailingObjects(OverloadToken<detail::TypeTagForDatatypeData>) const { + return IsTypeTagForDatatype; + } + size_t numTrailingObjects(OverloadToken<ParsedType>) const { + return HasParsedType; + } + size_t numTrailingObjects(OverloadToken<detail::PropertyData>) const { + return IsProperty; + } + public: /// The style used to specify an attribute. enum Syntax { @@ -182,34 +214,18 @@ private: const Expr *MessageExpr; - /// Arguments, if any, are stored immediately following the object. - ArgsUnion *getArgsBuffer() { return reinterpret_cast<ArgsUnion *>(this + 1); } + ArgsUnion *getArgsBuffer() { return getTrailingObjects<ArgsUnion>(); } ArgsUnion const *getArgsBuffer() const { - return reinterpret_cast<ArgsUnion const *>(this + 1); + return getTrailingObjects<ArgsUnion>(); } - /// Availability information is stored immediately following the arguments, - /// if any, at the end of the object. - AvailabilityData *getAvailabilityData() { - return reinterpret_cast<AvailabilityData*>(getArgsBuffer() + NumArgs); + detail::AvailabilityData *getAvailabilityData() { + return getTrailingObjects<detail::AvailabilityData>(); } - const AvailabilityData *getAvailabilityData() const { - return reinterpret_cast<const AvailabilityData*>(getArgsBuffer() + NumArgs); + const detail::AvailabilityData *getAvailabilityData() const { + return getTrailingObjects<detail::AvailabilityData>(); } -public: - struct TypeTagForDatatypeData { - ParsedType *MatchingCType; - unsigned LayoutCompatible : 1; - unsigned MustBeNull : 1; - }; - struct PropertyData { - IdentifierInfo *GetterId, *SetterId; - - PropertyData(IdentifierInfo *getterId, IdentifierInfo *setterId) - : GetterId(getterId), SetterId(setterId) {} - }; - private: friend class AttributeFactory; friend class AttributePool; @@ -244,7 +260,7 @@ private: MessageExpr(messageExpr) { ArgsUnion PVal(Parm); memcpy(getArgsBuffer(), &PVal, sizeof(ArgsUnion)); - new (getAvailabilityData()) AvailabilityData( + new (getAvailabilityData()) detail::AvailabilityData( introduced, deprecated, obsoleted, strict, replacementExpr); AttrKind = getKind(getName(), getScopeName(), syntaxUsed); } @@ -278,7 +294,7 @@ private: HasProcessingCache(false) { ArgsUnion PVal(ArgKind); memcpy(getArgsBuffer(), &PVal, sizeof(ArgsUnion)); - TypeTagForDatatypeData &ExtraData = getTypeTagForDatatypeDataSlot(); + detail::TypeTagForDatatypeData &ExtraData = getTypeTagForDatatypeDataSlot(); new (&ExtraData.MatchingCType) ParsedType(matchingCType); ExtraData.LayoutCompatible = layoutCompatible; ExtraData.MustBeNull = mustBeNull; @@ -308,46 +324,45 @@ private: UsedAsTypeAttr(false), IsAvailability(false), IsTypeTagForDatatype(false), IsProperty(true), HasParsedType(false), HasProcessingCache(false) { - new (&getPropertyDataBuffer()) PropertyData(getterId, setterId); + new (&getPropertyDataBuffer()) detail::PropertyData(getterId, setterId); AttrKind = getKind(getName(), getScopeName(), syntaxUsed); } /// Type tag information is stored immediately following the arguments, if /// any, at the end of the object. They are mutually exclusive with /// availability slots. - TypeTagForDatatypeData &getTypeTagForDatatypeDataSlot() { - return *reinterpret_cast<TypeTagForDatatypeData*>(getArgsBuffer()+NumArgs); + detail::TypeTagForDatatypeData &getTypeTagForDatatypeDataSlot() { + return *getTrailingObjects<detail::TypeTagForDatatypeData>(); } - const TypeTagForDatatypeData &getTypeTagForDatatypeDataSlot() const { - return *reinterpret_cast<const TypeTagForDatatypeData*>(getArgsBuffer() - + NumArgs); + const detail::TypeTagForDatatypeData &getTypeTagForDatatypeDataSlot() const { + return *getTrailingObjects<detail::TypeTagForDatatypeData>(); } /// The type buffer immediately follows the object and are mutually exclusive /// with arguments. - ParsedType &getTypeBuffer() { - return *reinterpret_cast<ParsedType *>(this + 1); - } + ParsedType &getTypeBuffer() { return *getTrailingObjects<ParsedType>(); } const ParsedType &getTypeBuffer() const { - return *reinterpret_cast<const ParsedType *>(this + 1); + return *getTrailingObjects<ParsedType>(); } /// The property data immediately follows the object is is mutually exclusive /// with arguments. - PropertyData &getPropertyDataBuffer() { + detail::PropertyData &getPropertyDataBuffer() { assert(IsProperty); - return *reinterpret_cast<PropertyData*>(this + 1); + return *getTrailingObjects<detail::PropertyData>(); } - const PropertyData &getPropertyDataBuffer() const { + const detail::PropertyData &getPropertyDataBuffer() const { assert(IsProperty); - return *reinterpret_cast<const PropertyData*>(this + 1); + return *getTrailingObjects<detail::PropertyData>(); } size_t allocated_size() const; public: ParsedAttr(const ParsedAttr &) = delete; + ParsedAttr(ParsedAttr &&) = delete; ParsedAttr &operator=(const ParsedAttr &) = delete; + ParsedAttr &operator=(ParsedAttr &&) = delete; ~ParsedAttr() = delete; void operator delete(void *) = delete; @@ -368,6 +383,11 @@ public: IdentifierInfo *getScopeName() const { return ScopeName; } SourceLocation getScopeLoc() const { return ScopeLoc; } + bool isGNUScope() const { + return ScopeName && + (ScopeName->isStr("gnu") || ScopeName->isStr("__gnu__")); + } + bool hasParsedType() const { return HasParsedType; } /// Is this the Microsoft __declspec(property) attribute? @@ -451,17 +471,17 @@ public: const AvailabilityChange &getAvailabilityIntroduced() const { assert(getKind() == AT_Availability && "Not an availability attribute"); - return getAvailabilityData()->Changes[IntroducedSlot]; + return getAvailabilityData()->Changes[detail::IntroducedSlot]; } const AvailabilityChange &getAvailabilityDeprecated() const { assert(getKind() == AT_Availability && "Not an availability attribute"); - return getAvailabilityData()->Changes[DeprecatedSlot]; + return getAvailabilityData()->Changes[detail::DeprecatedSlot]; } const AvailabilityChange &getAvailabilityObsoleted() const { assert(getKind() == AT_Availability && "Not an availability attribute"); - return getAvailabilityData()->Changes[ObsoletedSlot]; + return getAvailabilityData()->Changes[detail::ObsoletedSlot]; } SourceLocation getStrictLoc() const { @@ -487,7 +507,7 @@ public: const ParsedType &getMatchingCType() const { assert(getKind() == AT_TypeTagForDatatype && "Not a type_tag_for_datatype attribute"); - return *getTypeTagForDatatypeDataSlot().MatchingCType; + return getTypeTagForDatatypeDataSlot().MatchingCType; } bool getLayoutCompatible() const { @@ -507,9 +527,16 @@ public: return getTypeBuffer(); } - const PropertyData &getPropertyData() const { - assert(isDeclspecPropertyAttribute() && "Not a __delcspec(property) attribute"); - return getPropertyDataBuffer(); + IdentifierInfo *getPropertyDataGetter() const { + assert(isDeclspecPropertyAttribute() && + "Not a __delcspec(property) attribute"); + return getPropertyDataBuffer().GetterId; + } + + IdentifierInfo *getPropertyDataSetter() const { + assert(isDeclspecPropertyAttribute() && + "Not a __delcspec(property) attribute"); + return getPropertyDataBuffer().SetterId; } /// Get an index into the attribute spelling list @@ -552,20 +579,18 @@ class AttributePool; class AttributeFactory { public: enum { - /// The required allocation size of an availability attribute, - /// which we want to ensure is a multiple of sizeof(void*). AvailabilityAllocSize = - sizeof(ParsedAttr) + - ((sizeof(AvailabilityData) + sizeof(void *) + sizeof(ArgsUnion) - 1) / - sizeof(void *) * sizeof(void *)), - TypeTagForDatatypeAllocSize = sizeof(ParsedAttr) + - (sizeof(ParsedAttr::TypeTagForDatatypeData) + - sizeof(void *) + sizeof(ArgsUnion) - 1) / - sizeof(void *) * sizeof(void *), + ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData, + detail::TypeTagForDatatypeData, ParsedType, + detail::PropertyData>(1, 1, 0, 0, 0), + TypeTagForDatatypeAllocSize = + ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData, + detail::TypeTagForDatatypeData, ParsedType, + detail::PropertyData>(1, 0, 1, 0, 0), PropertyAllocSize = - sizeof(ParsedAttr) + - (sizeof(ParsedAttr::PropertyData) + sizeof(void *) - 1) / - sizeof(void *) * sizeof(void *) + ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData, + detail::TypeTagForDatatypeData, ParsedType, + detail::PropertyData>(0, 0, 0, 0, 1), }; private: @@ -656,7 +681,16 @@ public: ArgsUnion *args, unsigned numArgs, ParsedAttr::Syntax syntax, SourceLocation ellipsisLoc = SourceLocation()) { - void *memory = allocate(sizeof(ParsedAttr) + numArgs * sizeof(ArgsUnion)); + size_t temp = + ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData, + detail::TypeTagForDatatypeData, ParsedType, + detail::PropertyData>(numArgs, 0, 0, 0, 0); + (void)temp; + void *memory = allocate( + ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData, + detail::TypeTagForDatatypeData, ParsedType, + detail::PropertyData>(numArgs, 0, 0, 0, + 0)); return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc, args, numArgs, syntax, ellipsisLoc)); } @@ -679,8 +713,10 @@ public: IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierLoc *Param1, IdentifierLoc *Param2, IdentifierLoc *Param3, ParsedAttr::Syntax syntax) { - size_t size = sizeof(ParsedAttr) + 3 * sizeof(ArgsUnion); - void *memory = allocate(size); + void *memory = allocate( + ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData, + detail::TypeTagForDatatypeData, ParsedType, + detail::PropertyData>(3, 0, 0, 0, 0)); return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc, Param1, Param2, Param3, syntax)); } @@ -702,7 +738,10 @@ public: IdentifierInfo *scopeName, SourceLocation scopeLoc, ParsedType typeArg, ParsedAttr::Syntax syntaxUsed) { - void *memory = allocate(sizeof(ParsedAttr) + sizeof(void *)); + void *memory = allocate( + ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData, + detail::TypeTagForDatatypeData, ParsedType, + detail::PropertyData>(0, 0, 0, 1, 0)); return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc, typeArg, syntaxUsed)); } @@ -728,10 +767,6 @@ public: ParsedAttr &operator[](SizeType pos) { return *AttrList[pos]; } const ParsedAttr &operator[](SizeType pos) const { return *AttrList[pos]; } - void addAtStart(ParsedAttr *newAttr) { - assert(newAttr); - AttrList.insert(AttrList.begin(), newAttr); - } void addAtEnd(ParsedAttr *newAttr) { assert(newAttr); AttrList.push_back(newAttr); @@ -785,6 +820,23 @@ public: iterator end() { return iterator(AttrList.end()); } const_iterator end() const { return const_iterator(AttrList.end()); } + ParsedAttr &front() { + assert(!empty()); + return *AttrList.front(); + } + const ParsedAttr &front() const { + assert(!empty()); + return *AttrList.front(); + } + ParsedAttr &back() { + assert(!empty()); + return *AttrList.back(); + } + const ParsedAttr &back() const { + assert(!empty()); + return *AttrList.back(); + } + bool hasAttribute(ParsedAttr::Kind K) const { return llvm::any_of( AttrList, [K](const ParsedAttr *AL) { return AL->getKind() == K; }); @@ -826,7 +878,7 @@ public: SourceLocation ellipsisLoc = SourceLocation()) { ParsedAttr *attr = pool.create(attrName, attrRange, scopeName, scopeLoc, args, numArgs, syntax, ellipsisLoc); - addAtStart(attr); + addAtEnd(attr); return attr; } @@ -842,7 +894,7 @@ public: ParsedAttr *attr = pool.create( attrName, attrRange, scopeName, scopeLoc, Param, introduced, deprecated, obsoleted, unavailable, MessageExpr, syntax, strict, ReplacementExpr); - addAtStart(attr); + addAtEnd(attr); return attr; } @@ -853,7 +905,7 @@ public: IdentifierLoc *Param3, ParsedAttr::Syntax syntax) { ParsedAttr *attr = pool.create(attrName, attrRange, scopeName, scopeLoc, Param1, Param2, Param3, syntax); - addAtStart(attr); + addAtEnd(attr); return attr; } @@ -867,7 +919,7 @@ public: ParsedAttr *attr = pool.createTypeTagForDatatype( attrName, attrRange, scopeName, scopeLoc, argumentKind, matchingCType, layoutCompatible, mustBeNull, syntax); - addAtStart(attr); + addAtEnd(attr); return attr; } @@ -878,7 +930,7 @@ public: ParsedAttr::Syntax syntaxUsed) { ParsedAttr *attr = pool.createTypeAttribute(attrName, attrRange, scopeName, scopeLoc, typeArg, syntaxUsed); - addAtStart(attr); + addAtEnd(attr); return attr; } @@ -891,7 +943,7 @@ public: ParsedAttr *attr = pool.createPropertyAttribute(attrName, attrRange, scopeName, scopeLoc, getterId, setterId, syntaxUsed); - addAtStart(attr); + addAtEnd(attr); return attr; } @@ -926,6 +978,34 @@ enum AttributeDeclKind { ExpectedFunctionWithProtoType, }; +inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, + const ParsedAttr &At) { + DB.AddTaggedVal(reinterpret_cast<intptr_t>(At.getName()), + DiagnosticsEngine::ak_identifierinfo); + return DB; +} + +inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, + const ParsedAttr &At) { + PD.AddTaggedVal(reinterpret_cast<intptr_t>(At.getName()), + DiagnosticsEngine::ak_identifierinfo); + return PD; +} + +inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, + const ParsedAttr *At) { + DB.AddTaggedVal(reinterpret_cast<intptr_t>(At->getName()), + DiagnosticsEngine::ak_identifierinfo); + return DB; +} + +inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, + const ParsedAttr *At) { + PD.AddTaggedVal(reinterpret_cast<intptr_t>(At->getName()), + DiagnosticsEngine::ak_identifierinfo); + return PD; +} + } // namespace clang #endif // LLVM_CLANG_SEMA_ATTRIBUTELIST_H diff --git a/include/clang/Sema/Scope.h b/include/clang/Sema/Scope.h index 11fa0362124b..9d9ab0514fb5 100644 --- a/include/clang/Sema/Scope.h +++ b/include/clang/Sema/Scope.h @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_SEMA_SCOPE_H #define LLVM_CLANG_SEMA_SCOPE_H +#include "clang/AST/Decl.h" #include "clang/Basic/Diagnostic.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/SmallPtrSet.h" diff --git a/include/clang/Sema/ScopeInfo.h b/include/clang/Sema/ScopeInfo.h index 5925fd6ccead..e09a68aba707 100644 --- a/include/clang/Sema/ScopeInfo.h +++ b/include/clang/Sema/ScopeInfo.h @@ -31,6 +31,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/ADT/TinyPtrVector.h" #include "llvm/Support/Casting.h" #include "llvm/Support/ErrorHandling.h" #include <algorithm> @@ -202,6 +203,12 @@ public: /// function. SmallVector<CompoundScopeInfo, 4> CompoundScopes; + /// The set of blocks that are introduced in this function. + llvm::SmallPtrSet<const BlockDecl *, 1> Blocks; + + /// The set of __block variables that are introduced in this function. + llvm::TinyPtrVector<VarDecl *> ByrefBlockVars; + /// A list of PartialDiagnostics created but delayed within the /// current function scope. These diagnostics are vetted for reachability /// prior to being emitted. @@ -426,6 +433,16 @@ public: (HasBranchProtectedScope && HasBranchIntoScope)); } + // Add a block introduced in this function. + void addBlock(const BlockDecl *BD) { + Blocks.insert(BD); + } + + // Add a __block variable introduced in this function. + void addByrefBlockVar(VarDecl *VD) { + ByrefBlockVars.push_back(VD); + } + bool isCoroutine() const { return !FirstCoroutineStmtLoc.isInvalid(); } void setFirstCoroutineStmt(SourceLocation Loc, StringRef Keyword) { diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index b1077c620f8a..e5b7465820a9 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -153,6 +153,7 @@ namespace clang { class ObjCPropertyDecl; class ObjCProtocolDecl; class OMPThreadPrivateDecl; + class OMPRequiresDecl; class OMPDeclareReductionDecl; class OMPDeclareSimdDecl; class OMPClause; @@ -306,6 +307,10 @@ class Sema { } bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New); + void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem, + QualType ResultTy, + ArrayRef<QualType> Args); + public: typedef OpaquePtr<DeclGroupRef> DeclGroupPtrTy; typedef OpaquePtr<TemplateName> TemplateTy; @@ -490,15 +495,24 @@ public: /// VisContext - Manages the stack for \#pragma GCC visibility. void *VisContext; // Really a "PragmaVisStack*" - /// This represents the stack of attributes that were pushed by - /// \#pragma clang attribute. + /// This an attribute introduced by \#pragma clang attribute. struct PragmaAttributeEntry { SourceLocation Loc; ParsedAttr *Attribute; SmallVector<attr::SubjectMatchRule, 4> MatchRules; bool IsUsed; }; - SmallVector<PragmaAttributeEntry, 2> PragmaAttributeStack; + + /// A push'd group of PragmaAttributeEntries. + struct PragmaAttributeGroup { + /// The location of the push attribute. + SourceLocation Loc; + /// The namespace of this push group. + const IdentifierInfo *Namespace; + SmallVector<PragmaAttributeEntry, 2> Entries; + }; + + SmallVector<PragmaAttributeGroup, 2> PragmaAttributeStack; /// The declaration that is currently receiving an attribute from the /// #pragma attribute stack. @@ -608,7 +622,15 @@ public: /// that had their exception spec checks delayed, plus the overridden /// function. SmallVector<std::pair<const CXXMethodDecl*, const CXXMethodDecl*>, 2> - DelayedExceptionSpecChecks; + DelayedOverridingExceptionSpecChecks; + + /// All the function redeclarations seen during a class definition that had + /// their exception spec checks delayed, plus the prior declaration they + /// should be checked against. Except during error recovery, the new decl + /// should always be a friend declaration, as that's the only valid way to + /// redeclare a special member before its class is complete. + SmallVector<std::pair<FunctionDecl*, FunctionDecl*>, 2> + DelayedEquivalentExceptionSpecChecks; /// All the members seen during a class definition which were both /// explicitly defaulted and had explicitly-specified exception @@ -983,6 +1005,8 @@ public: /// expressions for which we have deferred checking the destructor. SmallVector<CXXBindTemporaryExpr *, 8> DelayedDecltypeBinds; + llvm::SmallPtrSet<const Expr *, 8> PossibleDerefs; + /// \brief Describes whether we are in an expression constext which we have /// to handle differently. enum ExpressionKind { @@ -1016,6 +1040,9 @@ public: /// A stack of expression evaluation contexts. SmallVector<ExpressionEvaluationContextRecord, 8> ExprEvalContexts; + /// Emit a warning for all pending noderef expressions that we recorded. + void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec); + /// Compute the mangling number context for a lambda expression or /// block literal. /// @@ -1342,6 +1369,7 @@ public: void PopCompoundScope(); sema::CompoundScopeInfo &getCurCompoundScope() const; + bool isCurCompoundStmtAStmtExpr() const; bool hasAnyUnrecoverableErrorsInThisFunction() const; @@ -1435,8 +1463,6 @@ public: TypeSourceInfo *GetTypeForDeclarator(Declarator &D, Scope *S); TypeSourceInfo *GetTypeForDeclaratorCast(Declarator &D, QualType FromTy); - TypeSourceInfo *GetTypeSourceInfoForDeclarator(Declarator &D, QualType T, - TypeSourceInfo *ReturnTypeInfo); /// Package the given type and TSI into a ParsedType. ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo); @@ -1530,6 +1556,17 @@ public: }; private: + /// Methods for marking which expressions involve dereferencing a pointer + /// marked with the 'noderef' attribute. Expressions are checked bottom up as + /// they are parsed, meaning that a noderef pointer may not be accessed. For + /// example, in `&*p` where `p` is a noderef pointer, we will first parse the + /// `*p`, but need to check that `address of` is called on it. This requires + /// keeping a container of all pending expressions and checking if the address + /// of them are eventually taken. + void CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E); + void CheckAddressOfNoDeref(const Expr *E); + void CheckMemberAccessOfNoDeref(const MemberExpr *E); + bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T, TypeDiagnoser *Diagnoser); @@ -1556,7 +1593,7 @@ public: /// visible at the specified location. void makeMergedDefinitionVisible(NamedDecl *ND); - bool isModuleVisible(const Module *M) { return VisibleModules.isVisible(M); } + bool isModuleVisible(const Module *M, bool ModulePrivate = false); /// Determine whether a declaration is visible to name lookup. bool isVisible(const NamedDecl *D) { @@ -1613,6 +1650,8 @@ public: SourceLocation Loc, const NamedDecl *D, ArrayRef<const NamedDecl *> Equiv); + bool isUsualDeallocationFunction(const CXXMethodDecl *FD); + bool isCompleteType(SourceLocation Loc, QualType T) { return !RequireCompleteTypeImpl(Loc, T, nullptr); } @@ -1925,7 +1964,7 @@ public: bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous); void CheckVariableDeclarationType(VarDecl *NewVD); bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit, - Expr *Init); + Expr *&Init); void CheckCompleteVariableDeclaration(VarDecl *VD); void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD); void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D); @@ -1950,6 +1989,8 @@ public: FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization); bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl); + bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD, + QualType NewT, QualType OldT); void CheckMain(FunctionDecl *FD, const DeclSpec &D); void CheckMSVCRTEntryPoint(FunctionDecl *FD); Attr *getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD, bool IsDefinition); @@ -1983,6 +2024,7 @@ public: SourceLocation AttrEnd); void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc); void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc); + void CheckStaticLocalForDllExport(VarDecl *VD); void FinalizeDeclaration(Decl *D); DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef<Decl *> Group); @@ -2456,11 +2498,11 @@ public: unsigned AttrSpellingListIndex); OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex); - InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, SourceRange Range, - IdentifierInfo *Ident, - unsigned AttrSpellingListIndex); - CommonAttr *mergeCommonAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, - unsigned AttrSpellingListIndex); + InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL); + InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, + const InternalLinkageAttr &AL); + CommonAttr *mergeCommonAttr(Decl *D, const ParsedAttr &AL); + CommonAttr *mergeCommonAttr(Decl *D, const CommonAttr &AL); void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK = AMK_Redeclaration); @@ -2714,13 +2756,15 @@ public: typedef llvm::SmallSetVector<DeclContext *, 16> AssociatedNamespaceSet; typedef llvm::SmallSetVector<CXXRecordDecl *, 16> AssociatedClassSet; - void AddOverloadCandidate(FunctionDecl *Function, - DeclAccessPair FoundDecl, + using ADLCallKind = CallExpr::ADLCallKind; + + void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef<Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false, bool PartialOverloading = false, bool AllowExplicit = false, + ADLCallKind IsADLCandidate = ADLCallKind::NotADL, ConversionSequenceList EarlyConversions = None); void AddFunctionCandidates(const UnresolvedSetImpl &Functions, ArrayRef<Expr *> Args, @@ -2754,13 +2798,12 @@ public: OverloadCandidateSet& CandidateSet, bool SuppressUserConversions = false, bool PartialOverloading = false); - void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, - DeclAccessPair FoundDecl, - TemplateArgumentListInfo *ExplicitTemplateArgs, - ArrayRef<Expr *> Args, - OverloadCandidateSet& CandidateSet, - bool SuppressUserConversions = false, - bool PartialOverloading = false); + void AddTemplateOverloadCandidate( + FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, + TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args, + OverloadCandidateSet &CandidateSet, bool SuppressUserConversions = false, + bool PartialOverloading = false, + ADLCallKind IsADLCandidate = ADLCallKind::NotADL); bool CheckNonDependentConversions(FunctionTemplateDecl *FunctionTemplate, ArrayRef<QualType> ParamTypes, ArrayRef<Expr *> Args, @@ -2826,11 +2869,7 @@ public: /// Find the failed Boolean condition within a given Boolean /// constant expression, and describe it with a string. - /// - /// \param AllowTopLevelCond Whether to allow the result to be the - /// complete top-level condition. - std::pair<Expr *, std::string> - findFailedBooleanCondition(Expr *Cond, bool AllowTopLevelCond); + std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond); /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any /// non-ArgDependent DiagnoseIfAttrs. @@ -3378,30 +3417,6 @@ public: /// Valid types should not have multiple attributes with different CCs. const AttributedType *getCallingConvAttributedType(QualType T) const; - /// Check whether a nullability type specifier can be added to the given - /// type. - /// - /// \param type The type to which the nullability specifier will be - /// added. On success, this type will be updated appropriately. - /// - /// \param nullability The nullability specifier to add. - /// - /// \param nullabilityLoc The location of the nullability specifier. - /// - /// \param isContextSensitive Whether this nullability specifier was - /// written as a context-sensitive keyword (in an Objective-C - /// method) or an Objective-C property attribute, rather than as an - /// underscored type specifier. - /// - /// \param allowArrayTypes Whether to accept nullability specifiers on an - /// array type (e.g., because it will decay to a pointer). - /// - /// \returns true if nullability cannot be applied, false otherwise. - bool checkNullabilityTypeSpecifier(QualType &type, NullabilityKind nullability, - SourceLocation nullabilityLoc, - bool isContextSensitive, - bool allowArrayTypes); - /// Stmt attributes - this routine is the top level dispatcher. StmtResult ProcessStmtAttributes(Stmt *Stmt, const ParsedAttributesView &Attrs, @@ -3675,16 +3690,17 @@ public: return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation()); } FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC) { - return FullExprArg(ActOnFinishFullExpr(Arg, CC).get()); + return FullExprArg( + ActOnFinishFullExpr(Arg, CC, /*DiscardedValue*/ false).get()); } FullExprArg MakeFullDiscardedValueExpr(Expr *Arg) { ExprResult FE = - ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(), - /*DiscardedValue*/ true); + ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(), + /*DiscardedValue*/ true); return FullExprArg(FE.get()); } - StmtResult ActOnExprStmt(ExprResult Arg); + StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue = true); StmtResult ActOnExprStmtError(); StmtResult ActOnNullStmt(SourceLocation SemiLoc, @@ -3790,12 +3806,14 @@ public: StmtResult ActOnCXXForRangeStmt(Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc, + Stmt *InitStmt, Stmt *LoopVar, SourceLocation ColonLoc, Expr *Collection, SourceLocation RParenLoc, BuildForRangeKind Kind); StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, + Stmt *InitStmt, SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End, Expr *Cond, Expr *Inc, @@ -3983,7 +4001,8 @@ public: void DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs, const ObjCInterfaceDecl *UnknownObjCClass, bool ObjCPropertyAccess, - bool AvoidPartialAvailabilityChecks = false); + bool AvoidPartialAvailabilityChecks = false, + ObjCInterfaceDecl *ClassReceiver = nullptr); bool makeUnavailableInSystemHeader(SourceLocation loc, UnavailableAttr::ImplicitReason reason); @@ -3998,7 +4017,8 @@ public: bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs, const ObjCInterfaceDecl *UnknownObjCClass = nullptr, bool ObjCPropertyAccess = false, - bool AvoidPartialAvailabilityChecks = false); + bool AvoidPartialAvailabilityChecks = false, + ObjCInterfaceDecl *ClassReciever = nullptr); void NoteDeletedFunction(FunctionDecl *FD); void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD); std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD); @@ -4223,7 +4243,7 @@ public: TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr); ExprResult BuildPredefinedExpr(SourceLocation Loc, - PredefinedExpr::IdentType IT); + PredefinedExpr::IdentKind IK); ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind); ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val); @@ -4376,12 +4396,11 @@ public: MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig = nullptr, bool IsExecConfig = false); - ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, - SourceLocation LParenLoc, - ArrayRef<Expr *> Arg, - SourceLocation RParenLoc, - Expr *Config = nullptr, - bool IsExecConfig = false); + ExprResult + BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, + ArrayRef<Expr *> Arg, SourceLocation RParenLoc, + Expr *Config = nullptr, bool IsExecConfig = false, + ADLCallKind UsesADL = ADLCallKind::NotADL); ExprResult ActOnCUDAExecConfigExpr(Scope *S, SourceLocation LLLLoc, MultiExprArg ExecConfig, @@ -4582,6 +4601,11 @@ private: // of a ComparisonCategoryType enumerator. llvm::SmallBitVector FullyCheckedComparisonCategories; + ValueDecl *tryLookupCtorInitMemberDecl(CXXRecordDecl *ClassDecl, + CXXScopeSpec &SS, + ParsedType TemplateTypeTy, + IdentifierInfo *MemberOrBase); + public: /// Lookup the specified comparison category types in the standard /// library, an check the VarDecls possibly returned by the operator<=> @@ -4799,7 +4823,7 @@ public: ImplicitExceptionSpecification ComputeDefaultedCopyCtorExceptionSpec(CXXMethodDecl *MD); - /// Determine what sort of exception specification a defautled + /// Determine what sort of exception specification a defaulted /// copy assignment operator of a class will have, and whether the /// parameter will be const. ImplicitExceptionSpecification @@ -4898,8 +4922,7 @@ public: /// /// C++11 says that user-defined destructors with no exception spec get one /// that looks as if the destructor was implicitly declared. - void AdjustDestructorExceptionSpec(CXXRecordDecl *ClassDecl, - CXXDestructorDecl *Destructor); + void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor); /// Define the specified inheriting constructor. void DefineInheritingConstructor(SourceLocation UseLoc, @@ -5100,7 +5123,7 @@ public: /// using the given declaration (which is either a class template or a /// class) along with the given qualifiers. /// along with the qualifiers placed on '*this'. - CXXThisScopeRAII(Sema &S, Decl *ContextDecl, unsigned CXXThisTypeQuals, + CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals, bool Enabled = true); ~CXXThisScopeRAII(); @@ -5185,6 +5208,15 @@ public: SourceRange DirectInitRange, Expr *Initializer); + /// Determine whether \p FD is an aligned allocation or deallocation + /// function that is unavailable. + bool isUnavailableAlignedAllocationFunction(const FunctionDecl &FD) const; + + /// Produce diagnostics if \p FD is an aligned allocation or deallocation + /// function that is unavailable. + void diagnoseUnavailableAlignedAllocation(const FunctionDecl &FD, + SourceLocation Loc); + bool CheckAllocatedType(QualType AllocType, SourceLocation Loc, SourceRange R); @@ -5314,14 +5346,12 @@ public: CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference); - ExprResult ActOnFinishFullExpr(Expr *Expr) { - return ActOnFinishFullExpr(Expr, Expr ? Expr->getExprLoc() - : SourceLocation()); + ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue) { + return ActOnFinishFullExpr( + Expr, Expr ? Expr->getExprLoc() : SourceLocation(), DiscardedValue); } ExprResult ActOnFinishFullExpr(Expr *Expr, SourceLocation CC, - bool DiscardedValue = false, - bool IsConstexpr = false, - bool IsLambdaInitCaptureInitializer = false); + bool DiscardedValue, bool IsConstexpr = false); StmtResult ActOnFinishFullStmt(Stmt *Stmt); // Marks SS invalid if it represents an incomplete type. @@ -5586,7 +5616,9 @@ public: void finishLambdaExplicitCaptures(sema::LambdaScopeInfo *LSI); /// Introduce the lambda parameters into scope. - void addLambdaParameters(CXXMethodDecl *CallOperator, Scope *CurScope); + void addLambdaParameters( + ArrayRef<LambdaIntroducer::LambdaCapture> Captures, + CXXMethodDecl *CallOperator, Scope *CurScope); /// Deduce a block or lambda's return type based on the return /// statements present in the body. @@ -6044,6 +6076,10 @@ public: AccessResult CheckMemberAccess(SourceLocation UseLoc, CXXRecordDecl *NamingClass, DeclAccessPair Found); + AccessResult + CheckStructuredBindingMemberAccess(SourceLocation UseLoc, + CXXRecordDecl *DecomposedClass, + DeclAccessPair Field); AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, Expr *ArgExpr, @@ -6057,7 +6093,8 @@ public: bool ForceCheck = false, bool ForceUnprivileged = false); void CheckLookupAccess(const LookupResult &R); - bool IsSimplyAccessible(NamedDecl *decl, DeclContext *Ctx); + bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass, + QualType BaseType); bool isSpecialMemberAccessibleForDeletion(CXXMethodDecl *decl, AccessSpecifier access, QualType objectType); @@ -6202,7 +6239,8 @@ public: bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, - TemplateParamListContext TPC); + TemplateParamListContext TPC, + SkipBodyInfo *SkipBody = nullptr); TemplateParameterList *MatchTemplateParametersToScopeSpecifier( SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, @@ -6322,9 +6360,9 @@ public: const TemplateArgumentListInfo &ExplicitTemplateArgs, LookupResult &Previous); - bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, - TemplateArgumentListInfo *ExplicitTemplateArgs, - LookupResult &Previous); + bool CheckFunctionTemplateSpecialization( + FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, + LookupResult &Previous, bool QualifiedFriend = false); bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous); void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous); @@ -7061,7 +7099,7 @@ public: QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, TypeSourceInfo *TSI, SourceRange Range, bool DirectInit, - Expr *Init); + Expr *&Init); TypeLoc getReturnTypeLoc(FunctionDecl *FD) const; @@ -7168,6 +7206,10 @@ public: /// has been used when naming a template-id. DefaultTemplateArgumentChecking, + /// We are computing the exception specification for a defaulted special + /// member function. + ExceptionSpecEvaluation, + /// We are instantiating the exception specification for a function /// template which was deferred until it was needed. ExceptionSpecInstantiation, @@ -7726,7 +7768,7 @@ public: SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext, - unsigned ThisTypeQuals); + Qualifiers ThisTypeQuals); void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto, const MultiLevelTemplateArgumentList &Args); bool SubstExceptionSpec(SourceLocation Loc, @@ -8071,10 +8113,6 @@ public: SourceLocation ProtocolRAngleLoc, bool FailOnError = false); - /// Check the application of the Objective-C '__kindof' qualifier to - /// the given type. - bool checkObjCKindOfType(QualType &type, SourceLocation loc); - /// Ensure attributes are consistent with type. /// \param [in, out] Attributes The attributes to check; they will /// be modified to be consistent with \p PropertyTy. @@ -8434,6 +8472,10 @@ public: /// \#pragma clang fp contract void ActOnPragmaFPContract(LangOptions::FPContractModeKind FPC); + /// ActOnPragmaFenvAccess - Called on well formed + /// \#pragma STDC FENV_ACCESS + void ActOnPragmaFEnvAccess(LangOptions::FEnvAccessModeKind FPC); + /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'. void AddAlignmentAttributesForRecord(RecordDecl *RD); @@ -8465,12 +8507,15 @@ public: /// the appropriate attribute. void AddCFAuditedAttribute(Decl *D); - /// Called on well-formed '\#pragma clang attribute push'. - void ActOnPragmaAttributePush(ParsedAttr &Attribute, SourceLocation PragmaLoc, - attr::ParsedSubjectMatchRuleSet Rules); + void ActOnPragmaAttributeAttribute(ParsedAttr &Attribute, + SourceLocation PragmaLoc, + attr::ParsedSubjectMatchRuleSet Rules); + void ActOnPragmaAttributeEmptyPush(SourceLocation PragmaLoc, + const IdentifierInfo *Namespace); /// Called on well-formed '\#pragma clang attribute pop'. - void ActOnPragmaAttributePop(SourceLocation PragmaLoc); + void ActOnPragmaAttributePop(SourceLocation PragmaLoc, + const IdentifierInfo *Namespace); /// Adds the attributes that have been specified using the /// '\#pragma clang attribute push' directives to the given declaration. @@ -8530,9 +8575,9 @@ public: void AddParameterABIAttr(SourceRange AttrRange, Decl *D, ParameterABI ABI, unsigned SpellingListIndex); - void AddNSConsumedAttr(SourceRange AttrRange, Decl *D, - unsigned SpellingListIndex, bool isNSConsumed, - bool isTemplateInstantiation); + enum class RetainOwnershipKind {NS, CF, OS}; + void AddXConsumedAttr(Decl *D, SourceRange SR, unsigned SpellingIndex, + RetainOwnershipKind K, bool IsTemplateInstantiation); bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type); @@ -8572,6 +8617,21 @@ public: llvm::StringRef getCurrentOpenCLExtension() const { return CurrOpenCLExtension; } + + /// Check if a function declaration \p FD associates with any + /// extensions present in OpenCLDeclExtMap and if so return the + /// extension(s) name(s). + std::string getOpenCLExtensionsFromDeclExtMap(FunctionDecl *FD); + + /// Check if a function type \p FT associates with any + /// extensions present in OpenCLTypeExtMap and if so return the + /// extension(s) name(s). + std::string getOpenCLExtensionsFromTypeExtMap(FunctionType *FT); + + /// Find an extension in an appropriate extension map and return its name + template<typename T, typename MapT> + std::string getOpenCLExtensionsFromExtMap(T* FT, MapT &Map); + void setCurrentOpenCLExtension(llvm::StringRef Ext) { CurrOpenCLExtension = Ext; } @@ -8616,8 +8676,8 @@ public: // private: void *VarDataSharingAttributesStack; - /// Set to true inside '#pragma omp declare target' region. - bool IsInOpenMPDeclareTargetContext = false; + /// Number of nested '#pragma omp declare target' directives. + unsigned DeclareTargetNestingLevel = 0; /// Initialization of data-sharing attributes stack. void InitDataSharingAttributesStack(); void DestroyDataSharingAttributesStack(); @@ -8662,10 +8722,14 @@ public: /// Check if the specified variable is used in one of the private /// clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP /// constructs. - VarDecl *isOpenMPCapturedDecl(ValueDecl *D) const; + VarDecl *isOpenMPCapturedDecl(ValueDecl *D); ExprResult getOpenMPCapturedExpr(VarDecl *Capture, ExprValueKind VK, ExprObjectKind OK, SourceLocation Loc); + /// If the current region is a loop-based region, mark the start of the loop + /// construct. + void startOpenMPLoop(); + /// Check if the specified variable is used in 'private' clause. /// \param Level Relative level of nested OpenMP construct for that the check /// is performed. @@ -8713,6 +8777,12 @@ public: /// Builds a new OpenMPThreadPrivateDecl and checks its correctness. OMPThreadPrivateDecl *CheckOMPThreadPrivateDecl(SourceLocation Loc, ArrayRef<Expr *> VarList); + /// Called on well-formed '#pragma omp requires'. + DeclGroupPtrTy ActOnOpenMPRequiresDirective(SourceLocation Loc, + ArrayRef<OMPClause *> ClauseList); + /// Check restrictions on Requires directive + OMPRequiresDecl *CheckOMPRequiresDecl(SourceLocation Loc, + ArrayRef<OMPClause *> Clauses); /// Check if the specified type is allowed to be used in 'omp declare /// reduction' construct. QualType ActOnOpenMPDeclareReductionType(SourceLocation TyLoc, @@ -8746,11 +8816,12 @@ public: OMPDeclareTargetDeclAttr::MapTypeTy MT, NamedDeclSetType &SameDirectiveDecls); /// Check declaration inside target region. - void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, - SourceLocation IdLoc = SourceLocation()); + void + checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, + SourceLocation IdLoc = SourceLocation()); /// Return true inside OpenMP declare target region. bool isInOpenMPDeclareTargetContext() const { - return IsInOpenMPDeclareTargetContext; + return DeclareTargetNestingLevel > 0; } /// Return true inside OpenMP target region. bool isInOpenMPTargetExecutionDirective() const; @@ -9105,7 +9176,7 @@ public: SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); - + OMPClause *ActOnOpenMPSingleExprWithArgClause( OpenMPClauseKind Kind, ArrayRef<unsigned> Arguments, Expr *Expr, SourceLocation StartLoc, SourceLocation LParenLoc, @@ -9153,6 +9224,26 @@ public: /// Called on well-formed 'nogroup' clause. OMPClause *ActOnOpenMPNogroupClause(SourceLocation StartLoc, SourceLocation EndLoc); + /// Called on well-formed 'unified_address' clause. + OMPClause *ActOnOpenMPUnifiedAddressClause(SourceLocation StartLoc, + SourceLocation EndLoc); + + /// Called on well-formed 'unified_address' clause. + OMPClause *ActOnOpenMPUnifiedSharedMemoryClause(SourceLocation StartLoc, + SourceLocation EndLoc); + + /// Called on well-formed 'reverse_offload' clause. + OMPClause *ActOnOpenMPReverseOffloadClause(SourceLocation StartLoc, + SourceLocation EndLoc); + + /// Called on well-formed 'dynamic_allocators' clause. + OMPClause *ActOnOpenMPDynamicAllocatorsClause(SourceLocation StartLoc, + SourceLocation EndLoc); + + /// Called on well-formed 'atomic_default_mem_order' clause. + OMPClause *ActOnOpenMPAtomicDefaultMemOrderClause( + OpenMPAtomicDefaultMemOrderClauseKind Kind, SourceLocation KindLoc, + SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); OMPClause *ActOnOpenMPVarListClause( OpenMPClauseKind Kind, ArrayRef<Expr *> Vars, Expr *TailExpr, @@ -9160,7 +9251,9 @@ public: SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, OpenMPDependClauseKind DepKind, - OpenMPLinearClauseKind LinKind, OpenMPMapClauseKind MapTypeModifier, + OpenMPLinearClauseKind LinKind, + ArrayRef<OpenMPMapModifierKind> MapTypeModifiers, + ArrayRef<SourceLocation> MapTypeModifiersLoc, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation DepLinMapLoc); /// Called on well-formed 'private' clause. @@ -9244,7 +9337,8 @@ public: SourceLocation EndLoc); /// Called on well-formed 'map' clause. OMPClause * - ActOnOpenMPMapClause(OpenMPMapClauseKind MapTypeModifier, + ActOnOpenMPMapClause(ArrayRef<OpenMPMapModifierKind> MapTypeModifiers, + ArrayRef<SourceLocation> MapTypeModifiersLoc, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList, SourceLocation StartLoc, @@ -9571,6 +9665,10 @@ public: AssignmentAction Action, CheckedConversionKind CCK); + ExprResult PerformQualificationConversion( + Expr *E, QualType Ty, ExprValueKind VK = VK_RValue, + CheckedConversionKind CCK = CCK_ImplicitConversion); + /// the following "Check" methods will return a valid/converted QualType /// or a null QualType (indicating an error diagnostic was issued). @@ -9762,21 +9860,20 @@ public: /// \param Method - May be null. /// \param [out] ReturnType - The return type of the send. /// \return true iff there were any incompatible types. - bool CheckMessageArgumentTypes(QualType ReceiverType, + bool CheckMessageArgumentTypes(const Expr *Receiver, QualType ReceiverType, MultiExprArg Args, Selector Sel, ArrayRef<SourceLocation> SelectorLocs, ObjCMethodDecl *Method, bool isClassMessage, - bool isSuperMessage, - SourceLocation lbrac, SourceLocation rbrac, - SourceRange RecRange, + bool isSuperMessage, SourceLocation lbrac, + SourceLocation rbrac, SourceRange RecRange, QualType &ReturnType, ExprValueKind &VK); /// Determine the result of a message send expression based on /// the type of the receiver, the method expected to receive the message, /// and the form of the message send. - QualType getMessageSendResultType(QualType ReceiverType, - ObjCMethodDecl *Method, - bool isClassMessage, bool isSuperMessage); + QualType getMessageSendResultType(const Expr *Receiver, QualType ReceiverType, + ObjCMethodDecl *Method, bool isClassMessage, + bool isSuperMessage); /// If the given expression involves a message send to a method /// with a related result type, emit a note describing what happened. @@ -10245,6 +10342,7 @@ public: struct CodeCompleteExpressionData; void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data); + void CodeCompleteExpression(Scope *S, QualType PreferredType); void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase, SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement); @@ -10255,16 +10353,27 @@ public: const VirtSpecifiers *VS = nullptr); void CodeCompleteBracketDeclarator(Scope *S); void CodeCompleteCase(Scope *S); - void CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef<Expr *> Args); - void CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc, - ArrayRef<Expr *> Args); + /// Reports signatures for a call to CodeCompleteConsumer and returns the + /// preferred type for the current argument. Returned type can be null. + QualType ProduceCallSignatureHelp(Scope *S, Expr *Fn, ArrayRef<Expr *> Args, + SourceLocation OpenParLoc); + QualType ProduceConstructorSignatureHelp(Scope *S, QualType Type, + SourceLocation Loc, + ArrayRef<Expr *> Args, + SourceLocation OpenParLoc); + QualType ProduceCtorInitMemberSignatureHelp(Scope *S, Decl *ConstructorDecl, + CXXScopeSpec SS, + ParsedType TemplateTypeTy, + ArrayRef<Expr *> ArgExprs, + IdentifierInfo *II, + SourceLocation OpenParLoc); void CodeCompleteInitializer(Scope *S, Decl *D); void CodeCompleteReturn(Scope *S); void CodeCompleteAfterIf(Scope *S); - void CodeCompleteAssignmentRHS(Scope *S, Expr *LHS); + void CodeCompleteBinaryRHS(Scope *S, Expr *LHS, tok::TokenKind Op); void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, - bool EnteringContext); + bool EnteringContext, QualType BaseType); void CodeCompleteUsing(Scope *S); void CodeCompleteUsingDirective(Scope *S); void CodeCompleteNamespaceDecl(Scope *S); @@ -10337,6 +10446,7 @@ public: IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument); + void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled); void CodeCompleteNaturalLanguage(); void CodeCompleteAvailabilityPlatformName(); void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, @@ -10515,7 +10625,8 @@ private: /// Check if there is a field shadowing. void CheckShadowInheritedFields(const SourceLocation &Loc, DeclarationName FieldName, - const CXXRecordDecl *RD); + const CXXRecordDecl *RD, + bool DeclIsField = true); /// Check if the given expression contains 'break' or 'continue' /// statement that produces control flow different from GCC. @@ -10658,7 +10769,9 @@ private: SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); } ~SavePendingParsedClassStateRAII() { - assert(S.DelayedExceptionSpecChecks.empty() && + assert(S.DelayedOverridingExceptionSpecChecks.empty() && + "there shouldn't be any pending delayed exception spec checks"); + assert(S.DelayedEquivalentExceptionSpecChecks.empty() && "there shouldn't be any pending delayed exception spec checks"); assert(S.DelayedDefaultedMemberExceptionSpecs.empty() && "there shouldn't be any pending delayed defaulted member " @@ -10670,13 +10783,19 @@ private: private: Sema &S; - decltype(DelayedExceptionSpecChecks) SavedExceptionSpecChecks; + decltype(DelayedOverridingExceptionSpecChecks) + SavedOverridingExceptionSpecChecks; + decltype(DelayedEquivalentExceptionSpecChecks) + SavedEquivalentExceptionSpecChecks; decltype(DelayedDefaultedMemberExceptionSpecs) SavedDefaultedMemberExceptionSpecs; decltype(DelayedDllExportClasses) SavedDllExportClasses; void swapSavedState() { - SavedExceptionSpecChecks.swap(S.DelayedExceptionSpecChecks); + SavedOverridingExceptionSpecChecks.swap( + S.DelayedOverridingExceptionSpecChecks); + SavedEquivalentExceptionSpecChecks.swap( + S.DelayedEquivalentExceptionSpecChecks); SavedDefaultedMemberExceptionSpecs.swap( S.DelayedDefaultedMemberExceptionSpecs); SavedDllExportClasses.swap(S.DelayedDllExportClasses); @@ -10790,7 +10909,6 @@ struct LateParsedTemplate { /// The template function declaration to be late parsed. Decl *D; }; - } // end namespace clang namespace llvm { diff --git a/include/clang/Sema/SemaDiagnostic.h b/include/clang/Sema/SemaDiagnostic.h index 7740d5e29c00..30a2497a3e87 100644 --- a/include/clang/Sema/SemaDiagnostic.h +++ b/include/clang/Sema/SemaDiagnostic.h @@ -10,19 +10,6 @@ #ifndef LLVM_CLANG_SEMA_SEMADIAGNOSTIC_H #define LLVM_CLANG_SEMA_SEMADIAGNOSTIC_H -#include "clang/Basic/Diagnostic.h" - -namespace clang { - namespace diag { - enum { -#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\ - SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) ENUM, -#define SEMASTART -#include "clang/Basic/DiagnosticSemaKinds.inc" -#undef DIAG - NUM_BUILTIN_SEMA_DIAGNOSTICS - }; - } // end namespace diag -} // end namespace clang +#include "clang/Basic/DiagnosticSema.h" #endif |
