[cfe-commits] r110945 - in /cfe/trunk: include/clang/Sema/ lib/Frontend/ lib/Sema/
Douglas Gregor
dgregor at apple.com
Thu Aug 12 13:07:11 PDT 2010
Author: dgregor
Date: Thu Aug 12 15:07:10 2010
New Revision: 110945
URL: http://llvm.org/viewvc/llvm-project?rev=110945&view=rev
Log:
Move Sema's headers into include/clang/Sema, renaming a few along the way.
Added:
cfe/trunk/include/clang/Sema/AnalysisBasedWarnings.h
- copied unchanged from r110939, cfe/trunk/lib/Sema/AnalysisBasedWarnings.h
cfe/trunk/include/clang/Sema/CXXFieldCollector.h
- copied unchanged from r110939, cfe/trunk/lib/Sema/CXXFieldCollector.h
cfe/trunk/include/clang/Sema/IdentifierResolver.h
- copied unchanged from r110939, cfe/trunk/lib/Sema/IdentifierResolver.h
cfe/trunk/include/clang/Sema/Initialization.h
- copied, changed from r110939, cfe/trunk/lib/Sema/SemaInit.h
cfe/trunk/include/clang/Sema/Lookup.h
- copied, changed from r110939, cfe/trunk/lib/Sema/Lookup.h
cfe/trunk/include/clang/Sema/Overload.h
- copied unchanged from r110939, cfe/trunk/lib/Sema/SemaOverload.h
cfe/trunk/include/clang/Sema/Sema.h
- copied, changed from r110939, cfe/trunk/lib/Sema/Sema.h
cfe/trunk/include/clang/Sema/Template.h
- copied unchanged from r110939, cfe/trunk/lib/Sema/SemaTemplate.h
Removed:
cfe/trunk/lib/Sema/AnalysisBasedWarnings.h
cfe/trunk/lib/Sema/CXXFieldCollector.h
cfe/trunk/lib/Sema/IdentifierResolver.h
cfe/trunk/lib/Sema/Lookup.h
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaInit.h
cfe/trunk/lib/Sema/SemaOverload.h
cfe/trunk/lib/Sema/SemaTemplate.h
Modified:
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
cfe/trunk/lib/Sema/IdentifierResolver.cpp
cfe/trunk/lib/Sema/JumpDiagnostics.cpp
cfe/trunk/lib/Sema/ParseAST.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaAccess.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/lib/Sema/SemaCXXCast.cpp
cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Sema/TargetAttributesSema.cpp
cfe/trunk/lib/Sema/TreeTransform.h
Copied: cfe/trunk/include/clang/Sema/Initialization.h (from r110939, cfe/trunk/lib/Sema/SemaInit.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?p2=cfe/trunk/include/clang/Sema/Initialization.h&p1=cfe/trunk/lib/Sema/SemaInit.h&r1=110939&r2=110945&rev=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.h (original)
+++ cfe/trunk/include/clang/Sema/Initialization.h Thu Aug 12 15:07:10 2010
@@ -10,10 +10,10 @@
// This file provides supporting data types for initialization of objects.
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_SEMA_INIT_H
-#define LLVM_CLANG_SEMA_INIT_H
+#ifndef LLVM_CLANG_SEMA_INITIALIZATION_H
+#define LLVM_CLANG_SEMA_INITIALIZATION_H
-#include "SemaOverload.h"
+#include "clang/Sema/Overload.h"
#include "clang/AST/Type.h"
#include "clang/AST/UnresolvedSet.h"
#include "clang/Parse/Action.h"
@@ -777,4 +777,4 @@
} // end namespace clang
-#endif // LLVM_CLANG_SEMA_INIT_H
+#endif // LLVM_CLANG_SEMA_INITIALIZATION_H
Copied: cfe/trunk/include/clang/Sema/Lookup.h (from r110939, cfe/trunk/lib/Sema/Lookup.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?p2=cfe/trunk/include/clang/Sema/Lookup.h&p1=cfe/trunk/lib/Sema/Lookup.h&r1=110939&r2=110945&rev=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Thu Aug 12 15:07:10 2010
@@ -15,7 +15,7 @@
#ifndef LLVM_CLANG_SEMA_LOOKUP_H
#define LLVM_CLANG_SEMA_LOOKUP_H
-#include "Sema.h"
+#include "clang/Sema/Sema.h"
namespace clang {
Copied: cfe/trunk/include/clang/Sema/Sema.h (from r110939, cfe/trunk/lib/Sema/Sema.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?p2=cfe/trunk/include/clang/Sema/Sema.h&p1=cfe/trunk/lib/Sema/Sema.h&r1=110939&r2=110945&rev=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Aug 12 15:07:10 2010
@@ -15,11 +15,11 @@
#ifndef LLVM_CLANG_AST_SEMA_H
#define LLVM_CLANG_AST_SEMA_H
-#include "IdentifierResolver.h"
-#include "CXXFieldCollector.h"
-#include "SemaOverload.h"
-#include "SemaTemplate.h"
-#include "AnalysisBasedWarnings.h"
+#include "clang/Sema/IdentifierResolver.h"
+#include "clang/Sema/CXXFieldCollector.h"
+#include "clang/Sema/Overload.h"
+#include "clang/Sema/Template.h"
+#include "clang/Sema/AnalysisBasedWarnings.h"
#include "clang/AST/Attr.h"
#include "clang/AST/DeclBase.h"
#include "clang/AST/Decl.h"
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Thu Aug 12 15:07:10 2010
@@ -15,7 +15,7 @@
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/PCHDeserializationListener.h"
#include "clang/Frontend/Utils.h"
-#include "../Sema/Sema.h" // FIXME: move Sema headers elsewhere
+#include "clang/Sema/Sema.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Expr.h"
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Thu Aug 12 15:07:10 2010
@@ -12,8 +12,8 @@
//===----------------------------------------------------------------------===//
#include "clang/Frontend/PCHWriter.h"
-#include "../Sema/Sema.h" // FIXME: move header into include/clang/Sema
-#include "../Sema/IdentifierResolver.h" // FIXME: move header
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/IdentifierResolver.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclContextInternals.h"
Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Thu Aug 12 15:07:10 2010
@@ -13,8 +13,8 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "AnalysisBasedWarnings.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/AnalysisBasedWarnings.h"
#include "clang/Basic/SourceManager.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/ExprCXX.h"
Removed: cfe/trunk/lib/Sema/AnalysisBasedWarnings.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.h?rev=110944&view=auto
==============================================================================
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.h (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.h (removed)
@@ -1,55 +0,0 @@
-//=- AnalysisBasedWarnings.h - Sema warnings based on libAnalysis -*- C++ -*-=//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines AnalysisBasedWarnings, a worker object used by Sema
-// that issues warnings based on dataflow-analysis.
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_SEMA_ANALYSIS_WARNINGS_H
-#define LLVM_CLANG_SEMA_ANALYSIS_WARNINGS_H
-
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/DenseMap.h"
-
-namespace clang {
-
-class Sema;
-
-namespace sema {
-
-class AnalysisBasedWarnings {
-public:
- class Policy {
- friend class AnalysisBasedWarnings;
- // The warnings to run.
- unsigned enableCheckFallThrough : 1;
- unsigned enableCheckUnreachable : 1;
- public:
- Policy();
- void disableCheckFallThrough() { enableCheckFallThrough = 0; }
- };
-
-private:
- Sema &S;
- Policy DefaultPolicy;
-
- enum VisitFlag { NotVisited = 0, Visited = 1, Pending = 2 };
- llvm::DenseMap<const FunctionDecl*, VisitFlag> VisitedFD;
-
-public:
- AnalysisBasedWarnings(Sema &s);
-
- Policy getDefaultPolicy() { return DefaultPolicy; }
-
- void IssueWarnings(Policy P, const Decl *D, QualType BlockTy = QualType());
-};
-
-}} // end namespace clang::sema
-
-#endif
Removed: cfe/trunk/lib/Sema/CXXFieldCollector.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CXXFieldCollector.h?rev=110944&view=auto
==============================================================================
--- cfe/trunk/lib/Sema/CXXFieldCollector.h (original)
+++ cfe/trunk/lib/Sema/CXXFieldCollector.h (removed)
@@ -1,79 +0,0 @@
-//===- CXXFieldCollector.h - Utility class for C++ class semantic analysis ===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides CXXFieldCollector that is used during parsing & semantic
-// analysis of C++ classes.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_SEMA_CXXFIELDCOLLECTOR_H
-#define LLVM_CLANG_SEMA_CXXFIELDCOLLECTOR_H
-
-#include "llvm/ADT/SmallVector.h"
-
-namespace clang {
- class FieldDecl;
-
-/// CXXFieldCollector - Used to keep track of CXXFieldDecls during parsing of
-/// C++ classes.
-class CXXFieldCollector {
- /// Fields - Contains all FieldDecls collected during parsing of a C++
- /// class. When a nested class is entered, its fields are appended to the
- /// fields of its parent class, when it is exited its fields are removed.
- llvm::SmallVector<FieldDecl*, 32> Fields;
-
- /// FieldCount - Each entry represents the number of fields collected during
- /// the parsing of a C++ class. When a nested class is entered, a new field
- /// count is pushed, when it is exited, the field count is popped.
- llvm::SmallVector<size_t, 4> FieldCount;
-
- // Example:
- //
- // class C {
- // int x,y;
- // class NC {
- // int q;
- // // At this point, Fields contains [x,y,q] decls and FieldCount contains
- // // [2,1].
- // };
- // int z;
- // // At this point, Fields contains [x,y,z] decls and FieldCount contains
- // // [3].
- // };
-
-public:
- /// StartClass - Called by Sema::ActOnStartCXXClassDef.
- void StartClass() { FieldCount.push_back(0); }
-
- /// Add - Called by Sema::ActOnCXXMemberDeclarator.
- void Add(FieldDecl *D) {
- Fields.push_back(D);
- ++FieldCount.back();
- }
-
- /// getCurNumField - The number of fields added to the currently parsed class.
- size_t getCurNumFields() const {
- assert(!FieldCount.empty() && "no currently-parsed class");
- return FieldCount.back();
- }
-
- /// getCurFields - Pointer to array of fields added to the currently parsed
- /// class.
- FieldDecl **getCurFields() { return &*(Fields.end() - getCurNumFields()); }
-
- /// FinishClass - Called by Sema::ActOnFinishCXXClassDef.
- void FinishClass() {
- Fields.resize(Fields.size() - getCurNumFields());
- FieldCount.pop_back();
- }
-};
-
-} // end namespace clang
-
-#endif
Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Thu Aug 12 15:07:10 2010
@@ -11,11 +11,11 @@
//
//===----------------------------------------------------------------------===//
#include "clang/Sema/CodeCompleteConsumer.h"
+#include "clang/Sema/Sema.h"
#include "clang/AST/DeclCXX.h"
#include "clang/Parse/Scope.h"
#include "clang/Lex/Preprocessor.h"
#include "clang-c/Index.h"
-#include "Sema.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
Modified: cfe/trunk/lib/Sema/IdentifierResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/IdentifierResolver.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/trunk/lib/Sema/IdentifierResolver.cpp Thu Aug 12 15:07:10 2010
@@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
-#include "IdentifierResolver.h"
+#include "clang/Sema/IdentifierResolver.h"
#include "clang/Basic/LangOptions.h"
using namespace clang;
Removed: cfe/trunk/lib/Sema/IdentifierResolver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/IdentifierResolver.h?rev=110944&view=auto
==============================================================================
--- cfe/trunk/lib/Sema/IdentifierResolver.h (original)
+++ cfe/trunk/lib/Sema/IdentifierResolver.h (removed)
@@ -1,203 +0,0 @@
-//===- IdentifierResolver.h - Lexical Scope Name lookup ---------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the IdentifierResolver class, which is used for lexical
-// scoped lookup, based on declaration names.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_AST_SEMA_IDENTIFIERRESOLVER_H
-#define LLVM_CLANG_AST_SEMA_IDENTIFIERRESOLVER_H
-
-#include "clang/Basic/IdentifierTable.h"
-#include "clang/Parse/Scope.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclarationName.h"
-#include "clang/AST/DeclCXX.h"
-
-namespace clang {
-
-/// IdentifierResolver - Keeps track of shadowed decls on enclosing
-/// scopes. It manages the shadowing chains of declaration names and
-/// implements efficent decl lookup based on a declaration name.
-class IdentifierResolver {
-
- /// IdDeclInfo - Keeps track of information about decls associated
- /// to a particular declaration name. IdDeclInfos are lazily
- /// constructed and assigned to a declaration name the first time a
- /// decl with that declaration name is shadowed in some scope.
- class IdDeclInfo {
- public:
- typedef llvm::SmallVector<NamedDecl*, 2> DeclsTy;
-
- inline DeclsTy::iterator decls_begin() { return Decls.begin(); }
- inline DeclsTy::iterator decls_end() { return Decls.end(); }
-
- void AddDecl(NamedDecl *D) { Decls.push_back(D); }
-
- /// RemoveDecl - Remove the decl from the scope chain.
- /// The decl must already be part of the decl chain.
- void RemoveDecl(NamedDecl *D);
-
- /// Replaces the Old declaration with the New declaration. If the
- /// replacement is successful, returns true. If the old
- /// declaration was not found, returns false.
- bool ReplaceDecl(NamedDecl *Old, NamedDecl *New);
-
- private:
- DeclsTy Decls;
- };
-
-public:
-
- /// iterator - Iterate over the decls of a specified declaration name.
- /// It will walk or not the parent declaration contexts depending on how
- /// it was instantiated.
- class iterator {
- public:
- typedef NamedDecl * value_type;
- typedef NamedDecl * reference;
- typedef NamedDecl * pointer;
- typedef std::input_iterator_tag iterator_category;
- typedef std::ptrdiff_t difference_type;
-
- /// Ptr - There are 3 forms that 'Ptr' represents:
- /// 1) A single NamedDecl. (Ptr & 0x1 == 0)
- /// 2) A IdDeclInfo::DeclsTy::iterator that traverses only the decls of the
- /// same declaration context. (Ptr & 0x3 == 0x1)
- /// 3) A IdDeclInfo::DeclsTy::iterator that traverses the decls of parent
- /// declaration contexts too. (Ptr & 0x3 == 0x3)
- uintptr_t Ptr;
- typedef IdDeclInfo::DeclsTy::iterator BaseIter;
-
- /// A single NamedDecl. (Ptr & 0x1 == 0)
- iterator(NamedDecl *D) {
- Ptr = reinterpret_cast<uintptr_t>(D);
- assert((Ptr & 0x1) == 0 && "Invalid Ptr!");
- }
- /// A IdDeclInfo::DeclsTy::iterator that walks or not the parent declaration
- /// contexts depending on 'LookInParentCtx'.
- iterator(BaseIter I) {
- Ptr = reinterpret_cast<uintptr_t>(I) | 0x1;
- }
-
- bool isIterator() const { return (Ptr & 0x1); }
-
- BaseIter getIterator() const {
- assert(isIterator() && "Ptr not an iterator!");
- return reinterpret_cast<BaseIter>(Ptr & ~0x3);
- }
-
- friend class IdentifierResolver;
- public:
- iterator() : Ptr(0) {}
-
- NamedDecl *operator*() const {
- if (isIterator())
- return *getIterator();
- else
- return reinterpret_cast<NamedDecl*>(Ptr);
- }
-
- bool operator==(const iterator &RHS) const {
- return Ptr == RHS.Ptr;
- }
- bool operator!=(const iterator &RHS) const {
- return Ptr != RHS.Ptr;
- }
-
- // Preincrement.
- iterator& operator++() {
- if (!isIterator()) // common case.
- Ptr = 0;
- else {
- NamedDecl *D = **this;
- void *InfoPtr = D->getDeclName().getFETokenInfo<void>();
- assert(!isDeclPtr(InfoPtr) && "Decl with wrong id ?");
- IdDeclInfo *Info = toIdDeclInfo(InfoPtr);
-
- BaseIter I = getIterator();
- if (I != Info->decls_begin())
- *this = iterator(I-1);
- else // No more decls.
- *this = iterator();
- }
- return *this;
- }
-
- uintptr_t getAsOpaqueValue() const { return Ptr; }
-
- static iterator getFromOpaqueValue(uintptr_t P) {
- iterator Result;
- Result.Ptr = P;
- return Result;
- }
- };
-
- /// begin - Returns an iterator for decls with the name 'Name'.
- static iterator begin(DeclarationName Name);
-
- /// end - Returns an iterator that has 'finished'.
- static iterator end() {
- return iterator();
- }
-
- /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
- /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
- /// true if 'D' belongs to the given declaration context.
- bool isDeclInScope(Decl *D, DeclContext *Ctx, ASTContext &Context,
- Scope *S = 0) const;
-
- /// AddDecl - Link the decl to its shadowed decl chain.
- void AddDecl(NamedDecl *D);
-
- /// RemoveDecl - Unlink the decl from its shadowed decl chain.
- /// The decl must already be part of the decl chain.
- void RemoveDecl(NamedDecl *D);
-
- /// Replace the decl Old with the new declaration New on its
- /// identifier chain. Returns true if the old declaration was found
- /// (and, therefore, replaced).
- bool ReplaceDecl(NamedDecl *Old, NamedDecl *New);
-
- /// \brief Link the declaration into the chain of declarations for
- /// the given identifier.
- ///
- /// This is a lower-level routine used by the PCH reader to link a
- /// declaration into a specific IdentifierInfo before the
- /// declaration actually has a name.
- void AddDeclToIdentifierChain(IdentifierInfo *II, NamedDecl *D);
-
- explicit IdentifierResolver(const LangOptions &LangOpt);
- ~IdentifierResolver();
-
-private:
- const LangOptions &LangOpt;
-
- class IdDeclInfoMap;
- IdDeclInfoMap *IdDeclInfos;
-
- /// FETokenInfo contains a Decl pointer if lower bit == 0.
- static inline bool isDeclPtr(void *Ptr) {
- return (reinterpret_cast<uintptr_t>(Ptr) & 0x1) == 0;
- }
-
- /// FETokenInfo contains a IdDeclInfo pointer if lower bit == 1.
- static inline IdDeclInfo *toIdDeclInfo(void *Ptr) {
- assert((reinterpret_cast<uintptr_t>(Ptr) & 0x1) == 1
- && "Ptr not a IdDeclInfo* !");
- return reinterpret_cast<IdDeclInfo*>(
- reinterpret_cast<uintptr_t>(Ptr) & ~0x1
- );
- }
-};
-
-} // end namespace clang
-
-#endif
Modified: cfe/trunk/lib/Sema/JumpDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/JumpDiagnostics.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/JumpDiagnostics.cpp (original)
+++ cfe/trunk/lib/Sema/JumpDiagnostics.cpp Thu Aug 12 15:07:10 2010
@@ -12,11 +12,11 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/ADT/BitVector.h"
-#include "Sema.h"
+#include "clang/Sema/Sema.h"
#include "clang/AST/Expr.h"
#include "clang/AST/StmtObjC.h"
#include "clang/AST/StmtCXX.h"
+#include "llvm/ADT/BitVector.h"
using namespace clang;
namespace {
Removed: cfe/trunk/lib/Sema/Lookup.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Lookup.h?rev=110944&view=auto
==============================================================================
--- cfe/trunk/lib/Sema/Lookup.h (original)
+++ cfe/trunk/lib/Sema/Lookup.h (removed)
@@ -1,681 +0,0 @@
-//===--- Lookup.h - Classes for name lookup ---------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the LookupResult class, which is integral to
-// Sema's name-lookup subsystem.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_SEMA_LOOKUP_H
-#define LLVM_CLANG_SEMA_LOOKUP_H
-
-#include "Sema.h"
-
-namespace clang {
-
-/// @brief Represents the results of name lookup.
-///
-/// An instance of the LookupResult class captures the results of a
-/// single name lookup, which can return no result (nothing found),
-/// a single declaration, a set of overloaded functions, or an
-/// ambiguity. Use the getKind() method to determine which of these
-/// results occurred for a given lookup.
-class LookupResult {
-public:
- enum LookupResultKind {
- /// @brief No entity found met the criteria.
- NotFound = 0,
-
- /// @brief No entity found met the criteria within the current
- /// instantiation,, but there were dependent base classes of the
- /// current instantiation that could not be searched.
- NotFoundInCurrentInstantiation,
-
- /// @brief Name lookup found a single declaration that met the
- /// criteria. getFoundDecl() will return this declaration.
- Found,
-
- /// @brief Name lookup found a set of overloaded functions that
- /// met the criteria.
- FoundOverloaded,
-
- /// @brief Name lookup found an unresolvable value declaration
- /// and cannot yet complete. This only happens in C++ dependent
- /// contexts with dependent using declarations.
- FoundUnresolvedValue,
-
- /// @brief Name lookup results in an ambiguity; use
- /// getAmbiguityKind to figure out what kind of ambiguity
- /// we have.
- Ambiguous
- };
-
- enum AmbiguityKind {
- /// Name lookup results in an ambiguity because multiple
- /// entities that meet the lookup criteria were found in
- /// subobjects of different types. For example:
- /// @code
- /// struct A { void f(int); }
- /// struct B { void f(double); }
- /// struct C : A, B { };
- /// void test(C c) {
- /// c.f(0); // error: A::f and B::f come from subobjects of different
- /// // types. overload resolution is not performed.
- /// }
- /// @endcode
- AmbiguousBaseSubobjectTypes,
-
- /// Name lookup results in an ambiguity because multiple
- /// nonstatic entities that meet the lookup criteria were found
- /// in different subobjects of the same type. For example:
- /// @code
- /// struct A { int x; };
- /// struct B : A { };
- /// struct C : A { };
- /// struct D : B, C { };
- /// int test(D d) {
- /// return d.x; // error: 'x' is found in two A subobjects (of B and C)
- /// }
- /// @endcode
- AmbiguousBaseSubobjects,
-
- /// Name lookup results in an ambiguity because multiple definitions
- /// of entity that meet the lookup criteria were found in different
- /// declaration contexts.
- /// @code
- /// namespace A {
- /// int i;
- /// namespace B { int i; }
- /// int test() {
- /// using namespace B;
- /// return i; // error 'i' is found in namespace A and A::B
- /// }
- /// }
- /// @endcode
- AmbiguousReference,
-
- /// Name lookup results in an ambiguity because an entity with a
- /// tag name was hidden by an entity with an ordinary name from
- /// a different context.
- /// @code
- /// namespace A { struct Foo {}; }
- /// namespace B { void Foo(); }
- /// namespace C {
- /// using namespace A;
- /// using namespace B;
- /// }
- /// void test() {
- /// C::Foo(); // error: tag 'A::Foo' is hidden by an object in a
- /// // different namespace
- /// }
- /// @endcode
- AmbiguousTagHiding
- };
-
- /// A little identifier for flagging temporary lookup results.
- enum TemporaryToken {
- Temporary
- };
-
- typedef UnresolvedSetImpl::iterator iterator;
-
- LookupResult(Sema &SemaRef, const DeclarationNameInfo &NameInfo,
- Sema::LookupNameKind LookupKind,
- Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration)
- : ResultKind(NotFound),
- Paths(0),
- NamingClass(0),
- SemaRef(SemaRef),
- NameInfo(NameInfo),
- LookupKind(LookupKind),
- IDNS(0),
- Redecl(Redecl != Sema::NotForRedeclaration),
- HideTags(true),
- Diagnose(Redecl == Sema::NotForRedeclaration)
- {
- configure();
- }
-
- // TODO: consider whether this constructor should be restricted to take
- // as input a const IndentifierInfo* (instead of Name),
- // forcing other cases towards the constructor taking a DNInfo.
- LookupResult(Sema &SemaRef, DeclarationName Name,
- SourceLocation NameLoc, Sema::LookupNameKind LookupKind,
- Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration)
- : ResultKind(NotFound),
- Paths(0),
- NamingClass(0),
- SemaRef(SemaRef),
- NameInfo(Name, NameLoc),
- LookupKind(LookupKind),
- IDNS(0),
- Redecl(Redecl != Sema::NotForRedeclaration),
- HideTags(true),
- Diagnose(Redecl == Sema::NotForRedeclaration)
- {
- configure();
- }
-
- /// Creates a temporary lookup result, initializing its core data
- /// using the information from another result. Diagnostics are always
- /// disabled.
- LookupResult(TemporaryToken _, const LookupResult &Other)
- : ResultKind(NotFound),
- Paths(0),
- NamingClass(0),
- SemaRef(Other.SemaRef),
- NameInfo(Other.NameInfo),
- LookupKind(Other.LookupKind),
- IDNS(Other.IDNS),
- Redecl(Other.Redecl),
- HideTags(Other.HideTags),
- Diagnose(false)
- {}
-
- ~LookupResult() {
- if (Diagnose) diagnose();
- if (Paths) deletePaths(Paths);
- }
-
- /// Gets the name info to look up.
- const DeclarationNameInfo &getLookupNameInfo() const {
- return NameInfo;
- }
-
- /// \brief Sets the name info to look up.
- void setLookupNameInfo(const DeclarationNameInfo &NameInfo) {
- this->NameInfo = NameInfo;
- }
-
- /// Gets the name to look up.
- DeclarationName getLookupName() const {
- return NameInfo.getName();
- }
-
- /// \brief Sets the name to look up.
- void setLookupName(DeclarationName Name) {
- NameInfo.setName(Name);
- }
-
- /// Gets the kind of lookup to perform.
- Sema::LookupNameKind getLookupKind() const {
- return LookupKind;
- }
-
- /// True if this lookup is just looking for an existing declaration.
- bool isForRedeclaration() const {
- return Redecl;
- }
-
- /// Sets whether tag declarations should be hidden by non-tag
- /// declarations during resolution. The default is true.
- void setHideTags(bool Hide) {
- HideTags = Hide;
- }
-
- bool isAmbiguous() const {
- return getResultKind() == Ambiguous;
- }
-
- /// Determines if this names a single result which is not an
- /// unresolved value using decl. If so, it is safe to call
- /// getFoundDecl().
- bool isSingleResult() const {
- return getResultKind() == Found;
- }
-
- /// Determines if the results are overloaded.
- bool isOverloadedResult() const {
- return getResultKind() == FoundOverloaded;
- }
-
- bool isUnresolvableResult() const {
- return getResultKind() == FoundUnresolvedValue;
- }
-
- LookupResultKind getResultKind() const {
- sanity();
- return ResultKind;
- }
-
- AmbiguityKind getAmbiguityKind() const {
- assert(isAmbiguous());
- return Ambiguity;
- }
-
- const UnresolvedSetImpl &asUnresolvedSet() const {
- return Decls;
- }
-
- iterator begin() const { return iterator(Decls.begin()); }
- iterator end() const { return iterator(Decls.end()); }
-
- /// \brief Return true if no decls were found
- bool empty() const { return Decls.empty(); }
-
- /// \brief Return the base paths structure that's associated with
- /// these results, or null if none is.
- CXXBasePaths *getBasePaths() const {
- return Paths;
- }
-
- /// \brief Tests whether the given declaration is acceptable.
- bool isAcceptableDecl(NamedDecl *D) const {
- return D->isInIdentifierNamespace(IDNS);
- }
-
- /// \brief Returns the identifier namespace mask for this lookup.
- unsigned getIdentifierNamespace() const {
- return IDNS;
- }
-
- /// \brief Returns whether these results arose from performing a
- /// lookup into a class.
- bool isClassLookup() const {
- return NamingClass != 0;
- }
-
- /// \brief Returns the 'naming class' for this lookup, i.e. the
- /// class which was looked into to find these results.
- ///
- /// C++0x [class.access.base]p5:
- /// The access to a member is affected by the class in which the
- /// member is named. This naming class is the class in which the
- /// member name was looked up and found. [Note: this class can be
- /// explicit, e.g., when a qualified-id is used, or implicit,
- /// e.g., when a class member access operator (5.2.5) is used
- /// (including cases where an implicit "this->" is added). If both
- /// a class member access operator and a qualified-id are used to
- /// name the member (as in p->T::m), the class naming the member
- /// is the class named by the nested-name-specifier of the
- /// qualified-id (that is, T). -- end note ]
- ///
- /// This is set by the lookup routines when they find results in a class.
- CXXRecordDecl *getNamingClass() const {
- return NamingClass;
- }
-
- /// \brief Sets the 'naming class' for this lookup.
- void setNamingClass(CXXRecordDecl *Record) {
- NamingClass = Record;
- }
-
- /// \brief Returns the base object type associated with this lookup;
- /// important for [class.protected]. Most lookups do not have an
- /// associated base object.
- QualType getBaseObjectType() const {
- return BaseObjectType;
- }
-
- /// \brief Sets the base object type for this lookup.
- void setBaseObjectType(QualType T) {
- BaseObjectType = T;
- }
-
- /// \brief Add a declaration to these results with its natural access.
- /// Does not test the acceptance criteria.
- void addDecl(NamedDecl *D) {
- addDecl(D, D->getAccess());
- }
-
- /// \brief Add a declaration to these results with the given access.
- /// Does not test the acceptance criteria.
- void addDecl(NamedDecl *D, AccessSpecifier AS) {
- Decls.addDecl(D, AS);
- ResultKind = Found;
- }
-
- /// \brief Add all the declarations from another set of lookup
- /// results.
- void addAllDecls(const LookupResult &Other) {
- Decls.append(Other.Decls.begin(), Other.Decls.end());
- ResultKind = Found;
- }
-
- /// \brief Determine whether no result was found because we could not
- /// search into dependent base classes of the current instantiation.
- bool wasNotFoundInCurrentInstantiation() const {
- return ResultKind == NotFoundInCurrentInstantiation;
- }
-
- /// \brief Note that while no result was found in the current instantiation,
- /// there were dependent base classes that could not be searched.
- void setNotFoundInCurrentInstantiation() {
- assert(ResultKind == NotFound && Decls.empty());
- ResultKind = NotFoundInCurrentInstantiation;
- }
-
- /// \brief Resolves the result kind of the lookup, possibly hiding
- /// decls.
- ///
- /// This should be called in any environment where lookup might
- /// generate multiple lookup results.
- void resolveKind();
-
- /// \brief Re-resolves the result kind of the lookup after a set of
- /// removals has been performed.
- void resolveKindAfterFilter() {
- if (Decls.empty()) {
- if (ResultKind != NotFoundInCurrentInstantiation)
- ResultKind = NotFound;
- } else {
- ResultKind = Found;
- resolveKind();
-
- if (Paths && (ResultKind != Ambiguous)) {
- deletePaths(Paths);
- Paths = 0;
- }
- }
- }
-
- template <class DeclClass>
- DeclClass *getAsSingle() const {
- if (getResultKind() != Found) return 0;
- return dyn_cast<DeclClass>(getFoundDecl());
- }
-
- /// \brief Fetch the unique decl found by this lookup. Asserts
- /// that one was found.
- ///
- /// This is intended for users who have examined the result kind
- /// and are certain that there is only one result.
- NamedDecl *getFoundDecl() const {
- assert(getResultKind() == Found
- && "getFoundDecl called on non-unique result");
- return (*begin())->getUnderlyingDecl();
- }
-
- /// Fetches a representative decl. Useful for lazy diagnostics.
- NamedDecl *getRepresentativeDecl() const {
- assert(!Decls.empty() && "cannot get representative of empty set");
- return *begin();
- }
-
- /// \brief Asks if the result is a single tag decl.
- bool isSingleTagDecl() const {
- return getResultKind() == Found && isa<TagDecl>(getFoundDecl());
- }
-
- /// \brief Make these results show that the name was found in
- /// base classes of different types.
- ///
- /// The given paths object is copied and invalidated.
- void setAmbiguousBaseSubobjectTypes(CXXBasePaths &P);
-
- /// \brief Make these results show that the name was found in
- /// distinct base classes of the same type.
- ///
- /// The given paths object is copied and invalidated.
- void setAmbiguousBaseSubobjects(CXXBasePaths &P);
-
- /// \brief Make these results show that the name was found in
- /// different contexts and a tag decl was hidden by an ordinary
- /// decl in a different context.
- void setAmbiguousQualifiedTagHiding() {
- setAmbiguous(AmbiguousTagHiding);
- }
-
- /// \brief Clears out any current state.
- void clear() {
- ResultKind = NotFound;
- Decls.clear();
- if (Paths) deletePaths(Paths);
- Paths = NULL;
- }
-
- /// \brief Clears out any current state and re-initializes for a
- /// different kind of lookup.
- void clear(Sema::LookupNameKind Kind) {
- clear();
- LookupKind = Kind;
- configure();
- }
-
- /// \brief Change this lookup's redeclaration kind.
- void setRedeclarationKind(Sema::RedeclarationKind RK) {
- Redecl = RK;
- configure();
- }
-
- void print(llvm::raw_ostream &);
-
- /// Suppress the diagnostics that would normally fire because of this
- /// lookup. This happens during (e.g.) redeclaration lookups.
- void suppressDiagnostics() {
- Diagnose = false;
- }
-
- /// Determines whether this lookup is suppressing diagnostics.
- bool isSuppressingDiagnostics() const {
- return Diagnose;
- }
-
- /// Sets a 'context' source range.
- void setContextRange(SourceRange SR) {
- NameContextRange = SR;
- }
-
- /// Gets the source range of the context of this name; for C++
- /// qualified lookups, this is the source range of the scope
- /// specifier.
- SourceRange getContextRange() const {
- return NameContextRange;
- }
-
- /// Gets the location of the identifier. This isn't always defined:
- /// sometimes we're doing lookups on synthesized names.
- SourceLocation getNameLoc() const {
- return NameInfo.getLoc();
- }
-
- /// \brief Get the Sema object that this lookup result is searching
- /// with.
- Sema &getSema() const { return SemaRef; }
-
- /// A class for iterating through a result set and possibly
- /// filtering out results. The results returned are possibly
- /// sugared.
- class Filter {
- LookupResult &Results;
- LookupResult::iterator I;
- bool Changed;
-#ifndef NDEBUG
- bool CalledDone;
-#endif
-
- friend class LookupResult;
- Filter(LookupResult &Results)
- : Results(Results), I(Results.begin()), Changed(false)
-#ifndef NDEBUG
- , CalledDone(false)
-#endif
- {}
-
- public:
-#ifndef NDEBUG
- ~Filter() {
- assert(CalledDone &&
- "LookupResult::Filter destroyed without done() call");
- }
-#endif
-
- bool hasNext() const {
- return I != Results.end();
- }
-
- NamedDecl *next() {
- assert(I != Results.end() && "next() called on empty filter");
- return *I++;
- }
-
- /// Erase the last element returned from this iterator.
- void erase() {
- Results.Decls.erase(--I);
- Changed = true;
- }
-
- /// Replaces the current entry with the given one, preserving the
- /// access bits.
- void replace(NamedDecl *D) {
- Results.Decls.replace(I-1, D);
- Changed = true;
- }
-
- /// Replaces the current entry with the given one.
- void replace(NamedDecl *D, AccessSpecifier AS) {
- Results.Decls.replace(I-1, D, AS);
- Changed = true;
- }
-
- void done() {
-#ifndef NDEBUG
- assert(!CalledDone && "done() called twice");
- CalledDone = true;
-#endif
-
- if (Changed)
- Results.resolveKindAfterFilter();
- }
- };
-
- /// Create a filter for this result set.
- Filter makeFilter() {
- return Filter(*this);
- }
-
-private:
- void diagnose() {
- if (isAmbiguous())
- SemaRef.DiagnoseAmbiguousLookup(*this);
- else if (isClassLookup() && SemaRef.getLangOptions().AccessControl)
- SemaRef.CheckLookupAccess(*this);
- }
-
- void setAmbiguous(AmbiguityKind AK) {
- ResultKind = Ambiguous;
- Ambiguity = AK;
- }
-
- void addDeclsFromBasePaths(const CXXBasePaths &P);
- void configure();
-
- // Sanity checks.
- void sanity() const {
- assert(ResultKind != NotFound || Decls.size() == 0);
- assert(ResultKind != Found || Decls.size() == 1);
- assert(ResultKind != FoundOverloaded || Decls.size() > 1 ||
- (Decls.size() == 1 &&
- isa<FunctionTemplateDecl>((*begin())->getUnderlyingDecl())));
- assert(ResultKind != FoundUnresolvedValue || sanityCheckUnresolved());
- assert(ResultKind != Ambiguous || Decls.size() > 1 ||
- (Decls.size() == 1 && Ambiguity == AmbiguousBaseSubobjects));
- assert((Paths != NULL) == (ResultKind == Ambiguous &&
- (Ambiguity == AmbiguousBaseSubobjectTypes ||
- Ambiguity == AmbiguousBaseSubobjects)));
- }
-
- bool sanityCheckUnresolved() const {
- for (iterator I = begin(), E = end(); I != E; ++I)
- if (isa<UnresolvedUsingValueDecl>(*I))
- return true;
- return false;
- }
-
- static void deletePaths(CXXBasePaths *);
-
- // Results.
- LookupResultKind ResultKind;
- AmbiguityKind Ambiguity; // ill-defined unless ambiguous
- UnresolvedSet<8> Decls;
- CXXBasePaths *Paths;
- CXXRecordDecl *NamingClass;
- QualType BaseObjectType;
-
- // Parameters.
- Sema &SemaRef;
- DeclarationNameInfo NameInfo;
- SourceRange NameContextRange;
- Sema::LookupNameKind LookupKind;
- unsigned IDNS; // set by configure()
-
- bool Redecl;
-
- /// \brief True if tag declarations should be hidden if non-tags
- /// are present
- bool HideTags;
-
- bool Diagnose;
-};
-
- /// \brief Consumes visible declarations found when searching for
- /// all visible names within a given scope or context.
- ///
- /// This abstract class is meant to be subclassed by clients of \c
- /// Sema::LookupVisibleDecls(), each of which should override the \c
- /// FoundDecl() function to process declarations as they are found.
- class VisibleDeclConsumer {
- public:
- /// \brief Destroys the visible declaration consumer.
- virtual ~VisibleDeclConsumer();
-
- /// \brief Invoked each time \p Sema::LookupVisibleDecls() finds a
- /// declaration visible from the current scope or context.
- ///
- /// \param ND the declaration found.
- ///
- /// \param Hiding a declaration that hides the declaration \p ND,
- /// or NULL if no such declaration exists.
- ///
- /// \param InBaseClass whether this declaration was found in base
- /// class of the context we searched.
- virtual void FoundDecl(NamedDecl *ND, NamedDecl *Hiding,
- bool InBaseClass) = 0;
- };
-
-/// \brief A class for storing results from argument-dependent lookup.
-class ADLResult {
-private:
- /// A map from canonical decls to the 'most recent' decl.
- llvm::DenseMap<NamedDecl*, NamedDecl*> Decls;
-
-public:
- /// Adds a new ADL candidate to this map.
- void insert(NamedDecl *D);
-
- /// Removes any data associated with a given decl.
- void erase(NamedDecl *D) {
- Decls.erase(cast<NamedDecl>(D->getCanonicalDecl()));
- }
-
- class iterator {
- typedef llvm::DenseMap<NamedDecl*,NamedDecl*>::iterator inner_iterator;
- inner_iterator iter;
-
- friend class ADLResult;
- iterator(const inner_iterator &iter) : iter(iter) {}
- public:
- iterator() {}
-
- iterator &operator++() { ++iter; return *this; }
- iterator operator++(int) { return iterator(iter++); }
-
- NamedDecl *operator*() const { return iter->second; }
-
- bool operator==(const iterator &other) const { return iter == other.iter; }
- bool operator!=(const iterator &other) const { return iter != other.iter; }
- };
-
- iterator begin() { return iterator(Decls.begin()); }
- iterator end() { return iterator(Decls.end()); }
-};
-
-}
-
-#endif
Modified: cfe/trunk/lib/Sema/ParseAST.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ParseAST.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/ParseAST.cpp (original)
+++ cfe/trunk/lib/Sema/ParseAST.cpp Thu Aug 12 15:07:10 2010
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Sema/ParseAST.h"
-#include "Sema.h"
+#include "clang/Sema/Sema.h"
#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/Sema/SemaConsumer.h"
#include "clang/Sema/ExternalSemaSource.h"
Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Thu Aug 12 15:07:10 2010
@@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
+#include "clang/Sema/Sema.h"
#include "TargetAttributesSema.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallSet.h"
Removed: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=110944&view=auto
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h (removed)
@@ -1,4771 +0,0 @@
-//===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the Sema class, which performs semantic analysis and
-// builds ASTs.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_AST_SEMA_H
-#define LLVM_CLANG_AST_SEMA_H
-
-#include "IdentifierResolver.h"
-#include "CXXFieldCollector.h"
-#include "SemaOverload.h"
-#include "SemaTemplate.h"
-#include "AnalysisBasedWarnings.h"
-#include "clang/AST/Attr.h"
-#include "clang/AST/DeclBase.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclObjC.h"
-#include "clang/AST/DeclTemplate.h"
-#include "clang/AST/ExprCXX.h"
-#include "clang/AST/FullExpr.h"
-#include "clang/Parse/Action.h"
-#include "clang/Sema/SemaDiagnostic.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/ADT/OwningPtr.h"
-#include <deque>
-#include <list>
-#include <map>
-#include <string>
-#include <vector>
-
-namespace llvm {
- class APSInt;
-}
-
-namespace clang {
- class ASTContext;
- class ASTConsumer;
- class CodeCompleteConsumer;
- class Preprocessor;
- class Decl;
- class DeclContext;
- class DeclSpec;
- class ExternalSemaSource;
- class NamedDecl;
- class Stmt;
- class Expr;
- class InitListExpr;
- class ParenListExpr;
- class DesignatedInitExpr;
- class CallExpr;
- class DeclRefExpr;
- class UnresolvedLookupExpr;
- class UnresolvedMemberExpr;
- class VarDecl;
- class ParmVarDecl;
- class TypedefDecl;
- class FunctionDecl;
- class QualType;
- class LangOptions;
- class Token;
- class IntegerLiteral;
- class StringLiteral;
- class ArrayType;
- class LabelStmt;
- class SwitchStmt;
- class CXXTryStmt;
- class ExtVectorType;
- class TypedefDecl;
- class TemplateDecl;
- class TemplateArgument;
- class TemplateArgumentLoc;
- class TemplateArgumentList;
- class TemplateParameterList;
- class TemplateTemplateParmDecl;
- class ClassTemplatePartialSpecializationDecl;
- class ClassTemplateDecl;
- class ObjCInterfaceDecl;
- class ObjCCompatibleAliasDecl;
- class ObjCProtocolDecl;
- class ObjCImplDecl;
- class ObjCImplementationDecl;
- class ObjCCategoryImplDecl;
- class ObjCCategoryDecl;
- class ObjCIvarDecl;
- class ObjCMethodDecl;
- class ObjCPropertyDecl;
- class ObjCContainerDecl;
- class PseudoDestructorTypeStorage;
- class FunctionProtoType;
- class CXXBasePath;
- class CXXBasePaths;
- class CXXTemporary;
- class LookupResult;
- class InitializedEntity;
- class InitializationKind;
- class InitializationSequence;
- class VisibleDeclConsumer;
- class TargetAttributesSema;
- class ADLResult;
-
-/// \brief Retains information about a function, method, or block that is
-/// currently being parsed.
-struct FunctionScopeInfo {
- /// \brief Whether this scope information structure defined information for
- /// a block.
- bool IsBlockInfo;
-
- /// \brief Whether this function contains a VLA, @try, try, C++
- /// initializer, or anything else that can't be jumped past.
- bool HasBranchProtectedScope;
-
- /// \brief Whether this function contains any switches or direct gotos.
- bool HasBranchIntoScope;
-
- /// \brief Whether this function contains any indirect gotos.
- bool HasIndirectGoto;
-
- /// \brief The number of errors that had occurred before starting this
- /// function or block.
- unsigned NumErrorsAtStartOfFunction;
-
- /// LabelMap - This is a mapping from label identifiers to the LabelStmt for
- /// it (which acts like the label decl in some ways). Forward referenced
- /// labels have a LabelStmt created for them with a null location & SubStmt.
- llvm::DenseMap<IdentifierInfo*, LabelStmt*> LabelMap;
-
- /// SwitchStack - This is the current set of active switch statements in the
- /// block.
- llvm::SmallVector<SwitchStmt*, 8> SwitchStack;
-
- /// \brief The list of return statements that occur within the function or
- /// block, if there is any chance of applying the named return value
- /// optimization.
- llvm::SmallVector<ReturnStmt *, 4> Returns;
-
- bool NeedsScopeChecking() const {
- return HasIndirectGoto ||
- (HasBranchProtectedScope && HasBranchIntoScope);
- }
-
- FunctionScopeInfo(unsigned NumErrors)
- : IsBlockInfo(false),
- HasBranchProtectedScope(false),
- HasBranchIntoScope(false),
- HasIndirectGoto(false),
- NumErrorsAtStartOfFunction(NumErrors) { }
-
- virtual ~FunctionScopeInfo();
-
- /// \brief Clear out the information in this function scope, making it
- /// suitable for reuse.
- void Clear(unsigned NumErrors);
-
- static bool classof(const FunctionScopeInfo *FSI) { return true; }
-};
-
-
-/// \brief Retains information about a block that is currently being parsed.
-struct BlockScopeInfo : FunctionScopeInfo {
- bool hasBlockDeclRefExprs;
-
- BlockDecl *TheDecl;
-
- /// TheScope - This is the scope for the block itself, which contains
- /// arguments etc.
- Scope *TheScope;
-
- /// ReturnType - The return type of the block, or null if the block
- /// signature didn't provide an explicit return type.
- QualType ReturnType;
-
- /// BlockType - The function type of the block, if one was given.
- /// Its return type may be BuiltinType::Dependent.
- QualType FunctionType;
-
- BlockScopeInfo(unsigned NumErrors, Scope *BlockScope, BlockDecl *Block)
- : FunctionScopeInfo(NumErrors), hasBlockDeclRefExprs(false),
- TheDecl(Block), TheScope(BlockScope)
- {
- IsBlockInfo = true;
- }
-
- virtual ~BlockScopeInfo();
-
- static bool classof(const FunctionScopeInfo *FSI) { return FSI->IsBlockInfo; }
- static bool classof(const BlockScopeInfo *BSI) { return true; }
-};
-
-/// \brief Holds a QualType and a TypeSourceInfo* that came out of a declarator
-/// parsing.
-///
-/// LocInfoType is a "transient" type, only needed for passing to/from Parser
-/// and Sema, when we want to preserve type source info for a parsed type.
-/// It will not participate in the type system semantics in any way.
-class LocInfoType : public Type {
- enum {
- // The last number that can fit in Type's TC.
- // Avoids conflict with an existing Type class.
- LocInfo = Type::TypeLast + 1
- };
-
- TypeSourceInfo *DeclInfo;
-
- LocInfoType(QualType ty, TypeSourceInfo *TInfo)
- : Type((TypeClass)LocInfo, ty, ty->isDependentType()), DeclInfo(TInfo) {
- assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in TC?");
- }
- friend class Sema;
-
-public:
- QualType getType() const { return getCanonicalTypeInternal(); }
- TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; }
-
- virtual void getAsStringInternal(std::string &Str,
- const PrintingPolicy &Policy) const;
-
- static bool classof(const Type *T) {
- return T->getTypeClass() == (TypeClass)LocInfo;
- }
- static bool classof(const LocInfoType *) { return true; }
-};
-
-/// Sema - This implements semantic analysis and AST building for C.
-class Sema : public Action {
- Sema(const Sema&); // DO NOT IMPLEMENT
- void operator=(const Sema&); // DO NOT IMPLEMENT
- mutable const TargetAttributesSema* TheTargetAttributesSema;
-public:
- const LangOptions &LangOpts;
- Preprocessor &PP;
- ASTContext &Context;
- ASTConsumer &Consumer;
- Diagnostic &Diags;
- SourceManager &SourceMgr;
-
- /// \brief Source of additional semantic information.
- ExternalSemaSource *ExternalSource;
-
- /// \brief Code-completion consumer.
- CodeCompleteConsumer *CodeCompleter;
-
- /// CurContext - This is the current declaration context of parsing.
- DeclContext *CurContext;
-
- /// VAListTagName - The declaration name corresponding to __va_list_tag.
- /// This is used as part of a hack to omit that class from ADL results.
- DeclarationName VAListTagName;
-
- /// A RAII object to temporarily push a declaration context.
- class ContextRAII {
- private:
- Sema &S;
- DeclContext *SavedContext;
-
- public:
- ContextRAII(Sema &S, DeclContext *ContextToPush)
- : S(S), SavedContext(S.CurContext) {
- assert(ContextToPush && "pushing null context");
- S.CurContext = ContextToPush;
- }
-
- void pop() {
- if (!SavedContext) return;
- S.CurContext = SavedContext;
- SavedContext = 0;
- }
-
- ~ContextRAII() {
- pop();
- }
- };
-
- /// PackContext - Manages the stack for #pragma pack. An alignment
- /// of 0 indicates default alignment.
- void *PackContext; // Really a "PragmaPackStack*"
-
- /// VisContext - Manages the stack for #pragma GCC visibility.
- void *VisContext; // Really a "PragmaVisStack*"
-
- /// \brief Stack containing information about each of the nested function,
- /// block, and method scopes that are currently active.
- llvm::SmallVector<FunctionScopeInfo *, 4> FunctionScopes;
-
- /// \brief Cached function scope object used for the top function scope
- /// and when there is no function scope (in error cases).
- ///
- /// This should never be accessed directly; rather, it's address will be
- /// pushed into \c FunctionScopes when we want to re-use it.
- FunctionScopeInfo TopFunctionScope;
-
- /// ExprTemporaries - This is the stack of temporaries that are created by
- /// the current full expression.
- llvm::SmallVector<CXXTemporary*, 8> ExprTemporaries;
-
- /// ExtVectorDecls - This is a list all the extended vector types. This allows
- /// us to associate a raw vector type with one of the ext_vector type names.
- /// This is only necessary for issuing pretty diagnostics.
- llvm::SmallVector<TypedefDecl*, 24> ExtVectorDecls;
-
- /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
- llvm::OwningPtr<CXXFieldCollector> FieldCollector;
-
- typedef llvm::SmallPtrSet<const CXXRecordDecl*, 8> RecordDeclSetTy;
-
- /// PureVirtualClassDiagSet - a set of class declarations which we have
- /// emitted a list of pure virtual functions. Used to prevent emitting the
- /// same list more than once.
- llvm::OwningPtr<RecordDeclSetTy> PureVirtualClassDiagSet;
-
- /// \brief A mapping from external names to the most recent
- /// locally-scoped external declaration with that name.
- ///
- /// This map contains external declarations introduced in local
- /// scoped, e.g.,
- ///
- /// \code
- /// void f() {
- /// void foo(int, int);
- /// }
- /// \endcode
- ///
- /// Here, the name "foo" will be associated with the declaration on
- /// "foo" within f. This name is not visible outside of
- /// "f". However, we still find it in two cases:
- ///
- /// - If we are declaring another external with the name "foo", we
- /// can find "foo" as a previous declaration, so that the types
- /// of this external declaration can be checked for
- /// compatibility.
- ///
- /// - If we would implicitly declare "foo" (e.g., due to a call to
- /// "foo" in C when no prototype or definition is visible), then
- /// we find this declaration of "foo" and complain that it is
- /// not visible.
- llvm::DenseMap<DeclarationName, NamedDecl *> LocallyScopedExternalDecls;
-
- /// \brief All the tentative definitions encountered in the TU.
- std::vector<VarDecl *> TentativeDefinitions;
-
- /// \brief The set of static functions seen so far that have not been used.
- std::vector<FunctionDecl*> UnusedStaticFuncs;
-
- class AccessedEntity {
- public:
- /// A member declaration found through lookup. The target is the
- /// member.
- enum MemberNonce { Member };
-
- /// A hierarchy (base-to-derived or derived-to-base) conversion.
- /// The target is the base class.
- enum BaseNonce { Base };
-
- bool isMemberAccess() const { return IsMember; }
-
- AccessedEntity(ASTContext &Context,
- MemberNonce _,
- CXXRecordDecl *NamingClass,
- DeclAccessPair FoundDecl,
- QualType BaseObjectType)
- : Access(FoundDecl.getAccess()), IsMember(true),
- Target(FoundDecl.getDecl()), NamingClass(NamingClass),
- BaseObjectType(BaseObjectType), Diag(0, Context.getDiagAllocator()) {
- }
-
- AccessedEntity(ASTContext &Context,
- BaseNonce _,
- CXXRecordDecl *BaseClass,
- CXXRecordDecl *DerivedClass,
- AccessSpecifier Access)
- : Access(Access), IsMember(false),
- Target(BaseClass), NamingClass(DerivedClass),
- Diag(0, Context.getDiagAllocator()) {
- }
-
- bool isQuiet() const { return Diag.getDiagID() == 0; }
-
- AccessSpecifier getAccess() const { return AccessSpecifier(Access); }
-
- // These apply to member decls...
- NamedDecl *getTargetDecl() const { return Target; }
- CXXRecordDecl *getNamingClass() const { return NamingClass; }
-
- // ...and these apply to hierarchy conversions.
- CXXRecordDecl *getBaseClass() const { return cast<CXXRecordDecl>(Target); }
- CXXRecordDecl *getDerivedClass() const { return NamingClass; }
-
- /// Retrieves the base object type, important when accessing
- /// an instance member.
- QualType getBaseObjectType() const { return BaseObjectType; }
-
- /// Sets a diagnostic to be performed. The diagnostic is given
- /// four (additional) arguments:
- /// %0 - 0 if the entity was private, 1 if protected
- /// %1 - the DeclarationName of the entity
- /// %2 - the TypeDecl type of the naming class
- /// %3 - the TypeDecl type of the declaring class
- void setDiag(const PartialDiagnostic &PDiag) {
- assert(isQuiet() && "partial diagnostic already defined");
- Diag = PDiag;
- }
- PartialDiagnostic &setDiag(unsigned DiagID) {
- assert(isQuiet() && "partial diagnostic already defined");
- assert(DiagID && "creating null diagnostic");
- Diag.Reset(DiagID);
- return Diag;
- }
- const PartialDiagnostic &getDiag() const {
- return Diag;
- }
-
- private:
- unsigned Access : 2;
- bool IsMember;
- NamedDecl *Target;
- CXXRecordDecl *NamingClass;
- QualType BaseObjectType;
- PartialDiagnostic Diag;
- };
-
- struct DelayedDiagnostic {
- enum DDKind { Deprecation, Access };
-
- unsigned char Kind; // actually a DDKind
- bool Triggered;
-
- SourceLocation Loc;
-
- union {
- /// Deprecation.
- struct { NamedDecl *Decl; } DeprecationData;
-
- /// Access control.
- char AccessData[sizeof(AccessedEntity)];
- };
-
- void destroy() {
- switch (Kind) {
- case Access: getAccessData().~AccessedEntity(); break;
- case Deprecation: break;
- }
- }
-
- static DelayedDiagnostic makeDeprecation(SourceLocation Loc,
- NamedDecl *D) {
- DelayedDiagnostic DD;
- DD.Kind = Deprecation;
- DD.Triggered = false;
- DD.Loc = Loc;
- DD.DeprecationData.Decl = D;
- return DD;
- }
-
- static DelayedDiagnostic makeAccess(SourceLocation Loc,
- const AccessedEntity &Entity) {
- DelayedDiagnostic DD;
- DD.Kind = Access;
- DD.Triggered = false;
- DD.Loc = Loc;
- new (&DD.getAccessData()) AccessedEntity(Entity);
- return DD;
- }
-
- AccessedEntity &getAccessData() {
- return *reinterpret_cast<AccessedEntity*>(AccessData);
- }
- const AccessedEntity &getAccessData() const {
- return *reinterpret_cast<const AccessedEntity*>(AccessData);
- }
- };
-
- /// \brief The stack of diagnostics that were delayed due to being
- /// produced during the parsing of a declaration.
- llvm::SmallVector<DelayedDiagnostic, 8> DelayedDiagnostics;
-
- /// \brief The depth of the current ParsingDeclaration stack.
- /// If nonzero, we are currently parsing a declaration (and
- /// hence should delay deprecation warnings).
- unsigned ParsingDeclDepth;
-
- /// WeakUndeclaredIdentifiers - Identifiers contained in
- /// #pragma weak before declared. rare. may alias another
- /// identifier, declared or undeclared
- class WeakInfo {
- IdentifierInfo *alias; // alias (optional)
- SourceLocation loc; // for diagnostics
- bool used; // identifier later declared?
- public:
- WeakInfo()
- : alias(0), loc(SourceLocation()), used(false) {}
- WeakInfo(IdentifierInfo *Alias, SourceLocation Loc)
- : alias(Alias), loc(Loc), used(false) {}
- inline IdentifierInfo * getAlias() const { return alias; }
- inline SourceLocation getLocation() const { return loc; }
- void setUsed(bool Used=true) { used = Used; }
- inline bool getUsed() { return used; }
- bool operator==(WeakInfo RHS) const {
- return alias == RHS.getAlias() && loc == RHS.getLocation();
- }
- bool operator!=(WeakInfo RHS) const { return !(*this == RHS); }
- };
- llvm::DenseMap<IdentifierInfo*,WeakInfo> WeakUndeclaredIdentifiers;
-
- /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
- /// #pragma weak during processing of other Decls.
- /// I couldn't figure out a clean way to generate these in-line, so
- /// we store them here and handle separately -- which is a hack.
- /// It would be best to refactor this.
- llvm::SmallVector<Decl*,2> WeakTopLevelDecl;
-
- IdentifierResolver IdResolver;
-
- /// Translation Unit Scope - useful to Objective-C actions that need
- /// to lookup file scope declarations in the "ordinary" C decl namespace.
- /// For example, user-defined classes, built-in "id" type, etc.
- Scope *TUScope;
-
- /// \brief The C++ "std" namespace, where the standard library resides.
- LazyDeclPtr StdNamespace;
-
- /// \brief The C++ "std::bad_alloc" class, which is defined by the C++
- /// standard library.
- LazyDeclPtr StdBadAlloc;
-
- /// A flag to remember whether the implicit forms of operator new and delete
- /// have been declared.
- bool GlobalNewDeleteDeclared;
-
- /// \brief The set of declarations that have been referenced within
- /// a potentially evaluated expression.
- typedef std::vector<std::pair<SourceLocation, Decl *> >
- PotentiallyReferencedDecls;
-
- /// \brief A set of diagnostics that may be emitted.
- typedef std::vector<std::pair<SourceLocation, PartialDiagnostic> >
- PotentiallyEmittedDiagnostics;
-
- /// \brief Data structure used to record current or nested
- /// expression evaluation contexts.
- struct ExpressionEvaluationContextRecord {
- /// \brief The expression evaluation context.
- ExpressionEvaluationContext Context;
-
- /// \brief The number of temporaries that were active when we
- /// entered this expression evaluation context.
- unsigned NumTemporaries;
-
- /// \brief The set of declarations referenced within a
- /// potentially potentially-evaluated context.
- ///
- /// When leaving a potentially potentially-evaluated context, each
- /// of these elements will be as referenced if the corresponding
- /// potentially potentially evaluated expression is potentially
- /// evaluated.
- PotentiallyReferencedDecls *PotentiallyReferenced;
-
- /// \brief The set of diagnostics to emit should this potentially
- /// potentially-evaluated context become evaluated.
- PotentiallyEmittedDiagnostics *PotentiallyDiagnosed;
-
- ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context,
- unsigned NumTemporaries)
- : Context(Context), NumTemporaries(NumTemporaries),
- PotentiallyReferenced(0), PotentiallyDiagnosed(0) { }
-
- void addReferencedDecl(SourceLocation Loc, Decl *Decl) {
- if (!PotentiallyReferenced)
- PotentiallyReferenced = new PotentiallyReferencedDecls;
- PotentiallyReferenced->push_back(std::make_pair(Loc, Decl));
- }
-
- void addDiagnostic(SourceLocation Loc, const PartialDiagnostic &PD) {
- if (!PotentiallyDiagnosed)
- PotentiallyDiagnosed = new PotentiallyEmittedDiagnostics;
- PotentiallyDiagnosed->push_back(std::make_pair(Loc, PD));
- }
-
- void Destroy() {
- delete PotentiallyReferenced;
- delete PotentiallyDiagnosed;
- PotentiallyReferenced = 0;
- PotentiallyDiagnosed = 0;
- }
- };
-
- /// A stack of expression evaluation contexts.
- llvm::SmallVector<ExpressionEvaluationContextRecord, 8> ExprEvalContexts;
-
- /// \brief Whether the code handled by Sema should be considered a
- /// complete translation unit or not.
- ///
- /// When true (which is generally the case), Sema will perform
- /// end-of-translation-unit semantic tasks (such as creating
- /// initializers for tentative definitions in C) once parsing has
- /// completed. This flag will be false when building PCH files,
- /// since a PCH file is by definition not a complete translation
- /// unit.
- bool CompleteTranslationUnit;
-
- llvm::BumpPtrAllocator BumpAlloc;
-
- /// \brief The number of SFINAE diagnostics that have been trapped.
- unsigned NumSFINAEErrors;
-
- typedef std::pair<ObjCMethodList, ObjCMethodList> GlobalMethods;
- typedef llvm::DenseMap<Selector, GlobalMethods> GlobalMethodPool;
-
- /// Method Pool - allows efficient lookup when typechecking messages to "id".
- /// We need to maintain a list, since selectors can have differing signatures
- /// across classes. In Cocoa, this happens to be extremely uncommon (only 1%
- /// of selectors are "overloaded").
- GlobalMethodPool MethodPool;
-
- /// Method selectors used in a @selector expression. Used for implementation
- /// of -Wselector.
- llvm::DenseMap<Selector, SourceLocation> ReferencedSelectors;
-
-
- GlobalMethodPool::iterator ReadMethodPool(Selector Sel);
-
- /// Private Helper predicate to check for 'self'.
- bool isSelfExpr(Expr *RExpr);
-public:
- Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
- bool CompleteTranslationUnit = true,
- CodeCompleteConsumer *CompletionConsumer = 0);
- ~Sema();
-
- const LangOptions &getLangOptions() const { return LangOpts; }
- Diagnostic &getDiagnostics() const { return Diags; }
- SourceManager &getSourceManager() const { return SourceMgr; }
- const TargetAttributesSema &getTargetAttributesSema() const;
-
- /// \brief Helper class that creates diagnostics with optional
- /// template instantiation stacks.
- ///
- /// This class provides a wrapper around the basic DiagnosticBuilder
- /// class that emits diagnostics. SemaDiagnosticBuilder is
- /// responsible for emitting the diagnostic (as DiagnosticBuilder
- /// does) and, if the diagnostic comes from inside a template
- /// instantiation, printing the template instantiation stack as
- /// well.
- class SemaDiagnosticBuilder : public DiagnosticBuilder {
- Sema &SemaRef;
- unsigned DiagID;
-
- public:
- SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned DiagID)
- : DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { }
-
- explicit SemaDiagnosticBuilder(Sema &SemaRef)
- : DiagnosticBuilder(DiagnosticBuilder::Suppress), SemaRef(SemaRef) { }
-
- ~SemaDiagnosticBuilder();
- };
-
- /// \brief Emit a diagnostic.
- SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
-
- /// \brief Emit a partial diagnostic.
- SemaDiagnosticBuilder Diag(SourceLocation Loc, const PartialDiagnostic& PD);
-
- /// \brief Build a partial diagnostic.
- PartialDiagnostic PDiag(unsigned DiagID = 0) {
- return PartialDiagnostic(DiagID, Context.getDiagAllocator());
- }
-
- virtual void DeleteExpr(ExprTy *E);
- virtual void DeleteStmt(StmtTy *S);
-
- OwningExprResult Owned(Expr* E) {
- assert(!E || E->isRetained());
- return OwningExprResult(*this, E);
- }
- OwningExprResult Owned(ExprResult R) {
- if (R.isInvalid())
- return ExprError();
- assert(!R.get() || ((Expr*) R.get())->isRetained());
- return OwningExprResult(*this, R.get());
- }
- OwningStmtResult Owned(Stmt* S) {
- assert(!S || S->isRetained());
- return OwningStmtResult(*this, S);
- }
-
- virtual void ActOnEndOfTranslationUnit();
-
- Scope *getScopeForContext(DeclContext *Ctx);
-
- void PushFunctionScope();
- void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
- void PopFunctionOrBlockScope();
-
- /// getLabelMap() - Return the current label map. If we're in a block, we
- /// return it.
- llvm::DenseMap<IdentifierInfo*, LabelStmt*> &getLabelMap() {
- if (FunctionScopes.empty())
- return TopFunctionScope.LabelMap;
-
- return FunctionScopes.back()->LabelMap;
- }
-
- /// getSwitchStack - This is returns the switch stack for the current block or
- /// function.
- llvm::SmallVector<SwitchStmt*,8> &getSwitchStack() {
- if (FunctionScopes.empty())
- return TopFunctionScope.SwitchStack;
-
- return FunctionScopes.back()->SwitchStack;
- }
-
- /// \brief Determine whether the current function or block needs scope
- /// checking.
- bool FunctionNeedsScopeChecking() {
- if (!FunctionScopes.empty())
- return FunctionScopes.back()->NeedsScopeChecking();
- return false;
- }
-
- void setFunctionHasBranchIntoScope() {
- if (!FunctionScopes.empty())
- FunctionScopes.back()->HasBranchIntoScope = true;
- }
-
- void setFunctionHasBranchProtectedScope() {
- if (!FunctionScopes.empty())
- FunctionScopes.back()->HasBranchProtectedScope = true;
- }
-
- void setFunctionHasIndirectGoto() {
- if (!FunctionScopes.empty())
- FunctionScopes.back()->HasIndirectGoto = true;
- }
-
-
- bool hasAnyErrorsInThisFunction() const;
-
- /// \brief Retrieve the current block, if any.
- BlockScopeInfo *getCurBlock();
-
- /// WeakTopLevelDeclDecls - access to #pragma weak-generated Decls
- llvm::SmallVector<Decl*,2> &WeakTopLevelDecls() { return WeakTopLevelDecl; }
-
- //===--------------------------------------------------------------------===//
- // Type Analysis / Processing: SemaType.cpp.
- //
-
- QualType adjustParameterType(QualType T);
- QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs);
- QualType BuildQualifiedType(QualType T, SourceLocation Loc, unsigned CVR) {
- return BuildQualifiedType(T, Loc, Qualifiers::fromCVRMask(CVR));
- }
- QualType BuildPointerType(QualType T,
- SourceLocation Loc, DeclarationName Entity);
- QualType BuildReferenceType(QualType T, bool LValueRef,
- SourceLocation Loc, DeclarationName Entity);
- QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
- Expr *ArraySize, unsigned Quals,
- SourceRange Brackets, DeclarationName Entity);
- QualType BuildExtVectorType(QualType T, ExprArg ArraySize,
- SourceLocation AttrLoc);
- QualType BuildFunctionType(QualType T,
- QualType *ParamTypes, unsigned NumParamTypes,
- bool Variadic, unsigned Quals,
- SourceLocation Loc, DeclarationName Entity,
- const FunctionType::ExtInfo &Info);
- QualType BuildMemberPointerType(QualType T, QualType Class,
- SourceLocation Loc,
- DeclarationName Entity);
- QualType BuildBlockPointerType(QualType T,
- SourceLocation Loc, DeclarationName Entity);
- TypeSourceInfo *GetTypeForDeclarator(Declarator &D, Scope *S,
- TagDecl **OwnedDecl = 0);
- TypeSourceInfo *GetTypeSourceInfoForDeclarator(Declarator &D, QualType T,
- TypeSourceInfo *ReturnTypeInfo);
- /// \brief Create a LocInfoType to hold the given QualType and TypeSourceInfo.
- QualType CreateLocInfoType(QualType T, TypeSourceInfo *TInfo);
- DeclarationNameInfo GetNameForDeclarator(Declarator &D);
- DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name);
- static QualType GetTypeFromParser(TypeTy *Ty, TypeSourceInfo **TInfo = 0);
- bool CheckSpecifiedExceptionType(QualType T, const SourceRange &Range);
- bool CheckDistantExceptionSpec(QualType T);
- bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New);
- bool CheckEquivalentExceptionSpec(
- const FunctionProtoType *Old, SourceLocation OldLoc,
- const FunctionProtoType *New, SourceLocation NewLoc);
- bool CheckEquivalentExceptionSpec(
- const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
- const FunctionProtoType *Old, SourceLocation OldLoc,
- const FunctionProtoType *New, SourceLocation NewLoc,
- bool *MissingExceptionSpecification = 0,
- bool *MissingEmptyExceptionSpecification = 0);
- bool CheckExceptionSpecSubset(
- const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
- const FunctionProtoType *Superset, SourceLocation SuperLoc,
- const FunctionProtoType *Subset, SourceLocation SubLoc);
- bool CheckParamExceptionSpec(const PartialDiagnostic & NoteID,
- const FunctionProtoType *Target, SourceLocation TargetLoc,
- const FunctionProtoType *Source, SourceLocation SourceLoc);
-
- virtual TypeResult ActOnTypeName(Scope *S, Declarator &D);
-
- bool RequireCompleteType(SourceLocation Loc, QualType T,
- const PartialDiagnostic &PD,
- std::pair<SourceLocation, PartialDiagnostic> Note);
- bool RequireCompleteType(SourceLocation Loc, QualType T,
- const PartialDiagnostic &PD);
- bool RequireCompleteType(SourceLocation Loc, QualType T,
- unsigned DiagID);
-
- QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
- const CXXScopeSpec &SS, QualType T);
-
- QualType BuildTypeofExprType(Expr *E);
- QualType BuildDecltypeType(Expr *E);
-
- //===--------------------------------------------------------------------===//
- // Symbol table / Decl tracking callbacks: SemaDecl.cpp.
- //
-
- /// getDeclName - Return a pretty name for the specified decl if possible, or
- /// an empty string if not. This is used for pretty crash reporting.
- virtual std::string getDeclName(DeclPtrTy D);
-
- DeclGroupPtrTy ConvertDeclToDeclGroup(DeclPtrTy Ptr);
-
- void DiagnoseUseOfUnimplementedSelectors();
-
- virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
- Scope *S, CXXScopeSpec *SS,
- bool isClassName = false,
- TypeTy *ObjectType = 0);
- virtual DeclSpec::TST isTagName(IdentifierInfo &II, Scope *S);
- virtual bool DiagnoseUnknownTypeName(const IdentifierInfo &II,
- SourceLocation IILoc,
- Scope *S,
- CXXScopeSpec *SS,
- TypeTy *&SuggestedType);
-
- virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D) {
- return HandleDeclarator(S, D, MultiTemplateParamsArg(*this), false);
- }
-
- DeclPtrTy HandleDeclarator(Scope *S, Declarator &D,
- MultiTemplateParamsArg TemplateParameterLists,
- bool IsFunctionDefinition);
- void RegisterLocallyScopedExternCDecl(NamedDecl *ND,
- const LookupResult &Previous,
- Scope *S);
- void DiagnoseFunctionSpecifiers(Declarator& D);
- void CheckShadow(Scope *S, VarDecl *D, const LookupResult& R);
- void CheckShadow(Scope *S, VarDecl *D);
- NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
- QualType R, TypeSourceInfo *TInfo,
- LookupResult &Previous, bool &Redeclaration);
- NamedDecl* ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
- QualType R, TypeSourceInfo *TInfo,
- LookupResult &Previous,
- MultiTemplateParamsArg TemplateParamLists,
- bool &Redeclaration);
- void CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous,
- bool &Redeclaration);
- NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
- QualType R, TypeSourceInfo *TInfo,
- LookupResult &Previous,
- MultiTemplateParamsArg TemplateParamLists,
- bool IsFunctionDefinition,
- bool &Redeclaration);
- void AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
- void CheckFunctionDeclaration(Scope *S,
- FunctionDecl *NewFD, LookupResult &Previous,
- bool IsExplicitSpecialization,
- bool &Redeclaration,
- bool &OverloadableAttrRequired);
- void CheckMain(FunctionDecl *FD);
- virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D);
- ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC,
- SourceLocation Loc,
- QualType T);
- ParmVarDecl *CheckParameter(DeclContext *DC,
- TypeSourceInfo *TSInfo, QualType T,
- IdentifierInfo *Name,
- SourceLocation NameLoc,
- VarDecl::StorageClass StorageClass,
- VarDecl::StorageClass StorageClassAsWritten);
- virtual void ActOnParamDefaultArgument(DeclPtrTy param,
- SourceLocation EqualLoc,
- ExprArg defarg);
- virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param,
- SourceLocation EqualLoc,
- SourceLocation ArgLoc);
- virtual void ActOnParamDefaultArgumentError(DeclPtrTy param);
- bool SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg,
- SourceLocation EqualLoc);
-
-
- // Contains the locations of the beginning of unparsed default
- // argument locations.
- llvm::DenseMap<ParmVarDecl *,SourceLocation> UnparsedDefaultArgLocs;
-
- virtual void AddInitializerToDecl(DeclPtrTy dcl, ExprArg init);
- void AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit);
- void ActOnUninitializedDecl(DeclPtrTy dcl, bool TypeContainsUndeducedAuto);
- virtual void ActOnInitializerError(DeclPtrTy Dcl);
- virtual void SetDeclDeleted(DeclPtrTy dcl, SourceLocation DelLoc);
- virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
- DeclPtrTy *Group,
- unsigned NumDecls);
- virtual void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
- SourceLocation LocAfterDecls);
- virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *S, Declarator &D);
- virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *S, DeclPtrTy D);
- virtual void ActOnStartOfObjCMethodDef(Scope *S, DeclPtrTy D);
-
- virtual DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body);
- DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body,
- bool IsInstantiation);
-
- /// \brief Diagnose any unused parameters in the given sequence of
- /// ParmVarDecl pointers.
- template<typename InputIterator>
- void DiagnoseUnusedParameters(InputIterator Param, InputIterator ParamEnd) {
- if (Diags.getDiagnosticLevel(diag::warn_unused_parameter) ==
- Diagnostic::Ignored)
- return;
-
- // Don't diagnose unused-parameter errors in template instantiations; we
- // will already have done so in the template itself.
- if (!ActiveTemplateInstantiations.empty())
- return;
-
- for (; Param != ParamEnd; ++Param) {
- if (!(*Param)->isUsed() && (*Param)->getDeclName() &&
- !(*Param)->template hasAttr<UnusedAttr>()) {
- Diag((*Param)->getLocation(), diag::warn_unused_parameter)
- << (*Param)->getDeclName();
- }
- }
- }
-
- void DiagnoseInvalidJumps(Stmt *Body);
- virtual DeclPtrTy ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg expr);
-
- /// Scope actions.
- virtual void ActOnPopScope(SourceLocation Loc, Scope *S);
- virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S);
-
- /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
- /// no declarator (e.g. "struct foo;") is parsed.
- virtual DeclPtrTy ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS,
- DeclSpec &DS);
-
- virtual DeclPtrTy BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
- AccessSpecifier AS,
- RecordDecl *Record);
-
- bool isAcceptableTagRedeclaration(const TagDecl *Previous,
- TagDecl::TagKind NewTag,
- SourceLocation NewTagLoc,
- const IdentifierInfo &Name);
-
- virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
- SourceLocation KWLoc, CXXScopeSpec &SS,
- IdentifierInfo *Name, SourceLocation NameLoc,
- AttributeList *Attr, AccessSpecifier AS,
- MultiTemplateParamsArg TemplateParameterLists,
- bool &OwnedDecl, bool &IsDependent);
-
- virtual TypeResult ActOnDependentTag(Scope *S,
- unsigned TagSpec,
- TagUseKind TUK,
- const CXXScopeSpec &SS,
- IdentifierInfo *Name,
- SourceLocation TagLoc,
- SourceLocation NameLoc);
-
- virtual void ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
- IdentifierInfo *ClassName,
- llvm::SmallVectorImpl<DeclPtrTy> &Decls);
- virtual DeclPtrTy ActOnField(Scope *S, DeclPtrTy TagD,
- SourceLocation DeclStart,
- Declarator &D, ExprTy *BitfieldWidth);
-
- FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
- Declarator &D, Expr *BitfieldWidth,
- AccessSpecifier AS);
-
- FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
- TypeSourceInfo *TInfo,
- RecordDecl *Record, SourceLocation Loc,
- bool Mutable, Expr *BitfieldWidth,
- SourceLocation TSSL,
- AccessSpecifier AS, NamedDecl *PrevDecl,
- Declarator *D = 0);
-
- enum CXXSpecialMember {
- CXXInvalid = -1,
- CXXConstructor = 0,
- CXXCopyConstructor = 1,
- CXXCopyAssignment = 2,
- CXXDestructor = 3
- };
- void DiagnoseNontrivial(const RecordType* Record, CXXSpecialMember mem);
- CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD);
-
- virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart,
- DeclPtrTy IntfDecl,
- Declarator &D, ExprTy *BitfieldWidth,
- tok::ObjCKeywordKind visibility);
-
- // This is used for both record definitions and ObjC interface declarations.
- virtual void ActOnFields(Scope* S,
- SourceLocation RecLoc, DeclPtrTy TagDecl,
- DeclPtrTy *Fields, unsigned NumFields,
- SourceLocation LBrac, SourceLocation RBrac,
- AttributeList *AttrList);
-
- /// ActOnTagStartDefinition - Invoked when we have entered the
- /// scope of a tag's definition (e.g., for an enumeration, class,
- /// struct, or union).
- virtual void ActOnTagStartDefinition(Scope *S, DeclPtrTy TagDecl);
-
- /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
- /// C++ record definition's base-specifiers clause and are starting its
- /// member declarations.
- virtual void ActOnStartCXXMemberDeclarations(Scope *S, DeclPtrTy TagDecl,
- SourceLocation LBraceLoc);
-
- /// ActOnTagFinishDefinition - Invoked once we have finished parsing
- /// the definition of a tag (enumeration, class, struct, or union).
- virtual void ActOnTagFinishDefinition(Scope *S, DeclPtrTy TagDecl,
- SourceLocation RBraceLoc);
-
- /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
- /// error parsing the definition of a tag.
- virtual void ActOnTagDefinitionError(Scope *S, DeclPtrTy TagDecl);
-
- EnumConstantDecl *CheckEnumConstant(EnumDecl *Enum,
- EnumConstantDecl *LastEnumConst,
- SourceLocation IdLoc,
- IdentifierInfo *Id,
- ExprArg val);
-
- virtual DeclPtrTy ActOnEnumConstant(Scope *S, DeclPtrTy EnumDecl,
- DeclPtrTy LastEnumConstant,
- SourceLocation IdLoc, IdentifierInfo *Id,
- SourceLocation EqualLoc, ExprTy *Val);
- virtual void ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
- SourceLocation RBraceLoc, DeclPtrTy EnumDecl,
- DeclPtrTy *Elements, unsigned NumElements,
- Scope *S, AttributeList *Attr);
-
- DeclContext *getContainingDC(DeclContext *DC);
-
- /// Set the current declaration context until it gets popped.
- void PushDeclContext(Scope *S, DeclContext *DC);
- void PopDeclContext();
-
- /// EnterDeclaratorContext - Used when we must lookup names in the context
- /// of a declarator's nested name specifier.
- void EnterDeclaratorContext(Scope *S, DeclContext *DC);
- void ExitDeclaratorContext(Scope *S);
-
- DeclContext *getFunctionLevelDeclContext();
-
- /// getCurFunctionDecl - If inside of a function body, this returns a pointer
- /// to the function decl for the function being parsed. If we're currently
- /// in a 'block', this returns the containing context.
- FunctionDecl *getCurFunctionDecl();
-
- /// getCurMethodDecl - If inside of a method body, this returns a pointer to
- /// the method decl for the method being parsed. If we're currently
- /// in a 'block', this returns the containing context.
- ObjCMethodDecl *getCurMethodDecl();
-
- /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
- /// or C function we're in, otherwise return null. If we're currently
- /// in a 'block', this returns the containing context.
- NamedDecl *getCurFunctionOrMethodDecl();
-
- /// Add this decl to the scope shadowed decl chains.
- void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
-
- /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
- /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
- /// true if 'D' belongs to the given declaration context.
- bool isDeclInScope(NamedDecl *&D, DeclContext *Ctx, Scope *S = 0);
-
- /// Finds the scope corresponding to the given decl context, if it
- /// happens to be an enclosing scope. Otherwise return NULL.
- Scope *getScopeForDeclContext(Scope *S, DeclContext *DC) {
- DeclContext *TargetDC = DC->getPrimaryContext();
- do {
- if (DeclContext *ScopeDC = (DeclContext*) S->getEntity())
- if (ScopeDC->getPrimaryContext() == TargetDC)
- return S;
- } while ((S = S->getParent()));
-
- return NULL;
- }
-
- /// Subroutines of ActOnDeclarator().
- TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T,
- TypeSourceInfo *TInfo);
- void MergeTypeDefDecl(TypedefDecl *New, LookupResult &OldDecls);
- bool MergeFunctionDecl(FunctionDecl *New, Decl *Old);
- bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old);
- void MergeVarDecl(VarDecl *New, LookupResult &OldDecls);
- bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old);
-
- // AssignmentAction - This is used by all the assignment diagnostic functions
- // to represent what is actually causing the operation
- enum AssignmentAction {
- AA_Assigning,
- AA_Passing,
- AA_Returning,
- AA_Converting,
- AA_Initializing,
- AA_Sending,
- AA_Casting
- };
-
- /// C++ Overloading.
- enum OverloadKind {
- /// This is a legitimate overload: the existing declarations are
- /// functions or function templates with different signatures.
- Ovl_Overload,
-
- /// This is not an overload because the signature exactly matches
- /// an existing declaration.
- Ovl_Match,
-
- /// This is not an overload because the lookup results contain a
- /// non-function.
- Ovl_NonFunction
- };
- OverloadKind CheckOverload(Scope *S,
- FunctionDecl *New,
- const LookupResult &OldDecls,
- NamedDecl *&OldDecl,
- bool IsForUsingDecl);
- bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl);
-
- bool TryImplicitConversion(InitializationSequence &Sequence,
- const InitializedEntity &Entity,
- Expr *From,
- bool SuppressUserConversions,
- bool AllowExplicit,
- bool InOverloadResolution);
-
- ImplicitConversionSequence
- TryImplicitConversion(Expr* From, QualType ToType,
- bool SuppressUserConversions,
- bool AllowExplicit,
- bool InOverloadResolution);
- bool IsStandardConversion(Expr *From, QualType ToType,
- bool InOverloadResolution,
- StandardConversionSequence& SCS);
- bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
- bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
- bool IsComplexPromotion(QualType FromType, QualType ToType);
- bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
- bool InOverloadResolution,
- QualType& ConvertedType, bool &IncompatibleObjC);
- bool isObjCPointerConversion(QualType FromType, QualType ToType,
- QualType& ConvertedType, bool &IncompatibleObjC);
- bool FunctionArgTypesAreEqual (FunctionProtoType* OldType,
- FunctionProtoType* NewType);
-
- bool CheckPointerConversion(Expr *From, QualType ToType,
- CastExpr::CastKind &Kind,
- CXXCastPath& BasePath,
- bool IgnoreBaseAccess);
- bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
- bool InOverloadResolution,
- QualType &ConvertedType);
- bool CheckMemberPointerConversion(Expr *From, QualType ToType,
- CastExpr::CastKind &Kind,
- CXXCastPath &BasePath,
- bool IgnoreBaseAccess);
- bool IsQualificationConversion(QualType FromType, QualType ToType);
- OverloadingResult IsUserDefinedConversion(Expr *From, QualType ToType,
- UserDefinedConversionSequence& User,
- OverloadCandidateSet& Conversions,
- bool AllowExplicit);
- bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType);
-
-
- ImplicitConversionSequence::CompareKind
- CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1,
- const ImplicitConversionSequence& ICS2);
-
- ImplicitConversionSequence::CompareKind
- CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
- const StandardConversionSequence& SCS2);
-
- ImplicitConversionSequence::CompareKind
- CompareQualificationConversions(const StandardConversionSequence& SCS1,
- const StandardConversionSequence& SCS2);
-
- ImplicitConversionSequence::CompareKind
- CompareDerivedToBaseConversions(const StandardConversionSequence& SCS1,
- const StandardConversionSequence& SCS2);
-
- OwningExprResult PerformCopyInitialization(const InitializedEntity &Entity,
- SourceLocation EqualLoc,
- OwningExprResult Init);
- ImplicitConversionSequence
- TryObjectArgumentInitialization(QualType FromType, CXXMethodDecl *Method,
- CXXRecordDecl *ActingContext);
- bool PerformObjectArgumentInitialization(Expr *&From,
- NestedNameSpecifier *Qualifier,
- NamedDecl *FoundDecl,
- CXXMethodDecl *Method);
-
- ImplicitConversionSequence TryContextuallyConvertToBool(Expr *From);
- bool PerformContextuallyConvertToBool(Expr *&From);
-
- ImplicitConversionSequence TryContextuallyConvertToObjCId(Expr *From);
- bool PerformContextuallyConvertToObjCId(Expr *&From);
-
- OwningExprResult
- ConvertToIntegralOrEnumerationType(SourceLocation Loc, ExprArg FromE,
- const PartialDiagnostic &NotIntDiag,
- const PartialDiagnostic &IncompleteDiag,
- const PartialDiagnostic &ExplicitConvDiag,
- const PartialDiagnostic &ExplicitConvNote,
- const PartialDiagnostic &AmbigDiag,
- const PartialDiagnostic &AmbigNote,
- const PartialDiagnostic &ConvDiag);
-
- bool PerformObjectMemberConversion(Expr *&From,
- NestedNameSpecifier *Qualifier,
- NamedDecl *FoundDecl,
- NamedDecl *Member);
-
- // Members have to be NamespaceDecl* or TranslationUnitDecl*.
- // TODO: make this is a typesafe union.
- typedef llvm::SmallPtrSet<DeclContext *, 16> AssociatedNamespaceSet;
- typedef llvm::SmallPtrSet<CXXRecordDecl *, 16> AssociatedClassSet;
-
- void AddOverloadCandidate(NamedDecl *Function,
- DeclAccessPair FoundDecl,
- Expr **Args, unsigned NumArgs,
- OverloadCandidateSet &CandidateSet);
-
- void AddOverloadCandidate(FunctionDecl *Function,
- DeclAccessPair FoundDecl,
- Expr **Args, unsigned NumArgs,
- OverloadCandidateSet& CandidateSet,
- bool SuppressUserConversions = false,
- bool PartialOverloading = false);
- void AddFunctionCandidates(const UnresolvedSetImpl &Functions,
- Expr **Args, unsigned NumArgs,
- OverloadCandidateSet& CandidateSet,
- bool SuppressUserConversions = false);
- void AddMethodCandidate(DeclAccessPair FoundDecl,
- QualType ObjectType,
- Expr **Args, unsigned NumArgs,
- OverloadCandidateSet& CandidateSet,
- bool SuppressUserConversion = false);
- void AddMethodCandidate(CXXMethodDecl *Method,
- DeclAccessPair FoundDecl,
- CXXRecordDecl *ActingContext, QualType ObjectType,
- Expr **Args, unsigned NumArgs,
- OverloadCandidateSet& CandidateSet,
- bool SuppressUserConversions = false);
- void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl,
- DeclAccessPair FoundDecl,
- CXXRecordDecl *ActingContext,
- const TemplateArgumentListInfo *ExplicitTemplateArgs,
- QualType ObjectType,
- Expr **Args, unsigned NumArgs,
- OverloadCandidateSet& CandidateSet,
- bool SuppressUserConversions = false);
- void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate,
- DeclAccessPair FoundDecl,
- const TemplateArgumentListInfo *ExplicitTemplateArgs,
- Expr **Args, unsigned NumArgs,
- OverloadCandidateSet& CandidateSet,
- bool SuppressUserConversions = false);
- void AddConversionCandidate(CXXConversionDecl *Conversion,
- DeclAccessPair FoundDecl,
- CXXRecordDecl *ActingContext,
- Expr *From, QualType ToType,
- OverloadCandidateSet& CandidateSet);
- void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate,
- DeclAccessPair FoundDecl,
- CXXRecordDecl *ActingContext,
- Expr *From, QualType ToType,
- OverloadCandidateSet &CandidateSet);
- void AddSurrogateCandidate(CXXConversionDecl *Conversion,
- DeclAccessPair FoundDecl,
- CXXRecordDecl *ActingContext,
- const FunctionProtoType *Proto,
- QualType ObjectTy, Expr **Args, unsigned NumArgs,
- OverloadCandidateSet& CandidateSet);
- void AddMemberOperatorCandidates(OverloadedOperatorKind Op,
- SourceLocation OpLoc,
- Expr **Args, unsigned NumArgs,
- OverloadCandidateSet& CandidateSet,
- SourceRange OpRange = SourceRange());
- void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys,
- Expr **Args, unsigned NumArgs,
- OverloadCandidateSet& CandidateSet,
- bool IsAssignmentOperator = false,
- unsigned NumContextualBoolArguments = 0);
- void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
- SourceLocation OpLoc,
- Expr **Args, unsigned NumArgs,
- OverloadCandidateSet& CandidateSet);
- void AddArgumentDependentLookupCandidates(DeclarationName Name,
- bool Operator,
- Expr **Args, unsigned NumArgs,
- const TemplateArgumentListInfo *ExplicitTemplateArgs,
- OverloadCandidateSet& CandidateSet,
- bool PartialOverloading = false);
- bool isBetterOverloadCandidate(const OverloadCandidate& Cand1,
- const OverloadCandidate& Cand2,
- SourceLocation Loc);
- OverloadingResult BestViableFunction(OverloadCandidateSet& CandidateSet,
- SourceLocation Loc,
- OverloadCandidateSet::iterator& Best);
-
- enum OverloadCandidateDisplayKind {
- /// Requests that all candidates be shown. Viable candidates will
- /// be printed first.
- OCD_AllCandidates,
-
- /// Requests that only viable candidates be shown.
- OCD_ViableCandidates
- };
- void PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,
- OverloadCandidateDisplayKind OCD,
- Expr **Args, unsigned NumArgs,
- const char *Opc = 0,
- SourceLocation Loc = SourceLocation());
-
- void NoteOverloadCandidate(FunctionDecl *Fn);
- void DiagnoseAmbiguousConversion(const ImplicitConversionSequence &ICS,
- SourceLocation CaretLoc,
- const PartialDiagnostic &PDiag);
-
- FunctionDecl *ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
- bool Complain,
- DeclAccessPair &Found);
- FunctionDecl *ResolveSingleFunctionTemplateSpecialization(Expr *From);
-
- Expr *FixOverloadedFunctionReference(Expr *E,
- DeclAccessPair FoundDecl,
- FunctionDecl *Fn);
- OwningExprResult FixOverloadedFunctionReference(OwningExprResult,
- DeclAccessPair FoundDecl,
- FunctionDecl *Fn);
-
- void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
- Expr **Args, unsigned NumArgs,
- OverloadCandidateSet &CandidateSet,
- bool PartialOverloading = false);
-
- OwningExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn,
- UnresolvedLookupExpr *ULE,
- SourceLocation LParenLoc,
- Expr **Args, unsigned NumArgs,
- SourceLocation *CommaLocs,
- SourceLocation RParenLoc);
-
- OwningExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc,
- unsigned Opc,
- const UnresolvedSetImpl &Fns,
- ExprArg input);
-
- OwningExprResult CreateOverloadedBinOp(SourceLocation OpLoc,
- unsigned Opc,
- const UnresolvedSetImpl &Fns,
- Expr *LHS, Expr *RHS);
-
- OwningExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
- SourceLocation RLoc,
- ExprArg Base,ExprArg Idx);
-
- OwningExprResult
- BuildCallToMemberFunction(Scope *S, Expr *MemExpr,
- SourceLocation LParenLoc, Expr **Args,
- unsigned NumArgs, SourceLocation *CommaLocs,
- SourceLocation RParenLoc);
- ExprResult
- BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc,
- Expr **Args, unsigned NumArgs,
- SourceLocation *CommaLocs,
- SourceLocation RParenLoc);
-
- OwningExprResult BuildOverloadedArrowExpr(Scope *S, ExprArg Base,
- SourceLocation OpLoc);
-
- /// CheckCallReturnType - Checks that a call expression's return type is
- /// complete. Returns true on failure. The location passed in is the location
- /// that best represents the call.
- bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
- CallExpr *CE, FunctionDecl *FD);
-
- /// Helpers for dealing with blocks and functions.
- bool CheckParmsForFunctionDef(FunctionDecl *FD);
- void CheckCXXDefaultArguments(FunctionDecl *FD);
- void CheckExtraCXXDefaultArguments(Declarator &D);
- Scope *getNonFieldDeclScope(Scope *S);
-
- /// \name Name lookup
- ///
- /// These routines provide name lookup that is used during semantic
- /// analysis to resolve the various kinds of names (identifiers,
- /// overloaded operator names, constructor names, etc.) into zero or
- /// more declarations within a particular scope. The major entry
- /// points are LookupName, which performs unqualified name lookup,
- /// and LookupQualifiedName, which performs qualified name lookup.
- ///
- /// All name lookup is performed based on some specific criteria,
- /// which specify what names will be visible to name lookup and how
- /// far name lookup should work. These criteria are important both
- /// for capturing language semantics (certain lookups will ignore
- /// certain names, for example) and for performance, since name
- /// lookup is often a bottleneck in the compilation of C++. Name
- /// lookup criteria is specified via the LookupCriteria enumeration.
- ///
- /// The results of name lookup can vary based on the kind of name
- /// lookup performed, the current language, and the translation
- /// unit. In C, for example, name lookup will either return nothing
- /// (no entity found) or a single declaration. In C++, name lookup
- /// can additionally refer to a set of overloaded functions or
- /// result in an ambiguity. All of the possible results of name
- /// lookup are captured by the LookupResult class, which provides
- /// the ability to distinguish among them.
- //@{
-
- /// @brief Describes the kind of name lookup to perform.
- enum LookupNameKind {
- /// Ordinary name lookup, which finds ordinary names (functions,
- /// variables, typedefs, etc.) in C and most kinds of names
- /// (functions, variables, members, types, etc.) in C++.
- LookupOrdinaryName = 0,
- /// Tag name lookup, which finds the names of enums, classes,
- /// structs, and unions.
- LookupTagName,
- /// Member name lookup, which finds the names of
- /// class/struct/union members.
- LookupMemberName,
- // Look up of an operator name (e.g., operator+) for use with
- // operator overloading. This lookup is similar to ordinary name
- // lookup, but will ignore any declarations that are class
- // members.
- LookupOperatorName,
- /// Look up of a name that precedes the '::' scope resolution
- /// operator in C++. This lookup completely ignores operator, object,
- /// function, and enumerator names (C++ [basic.lookup.qual]p1).
- LookupNestedNameSpecifierName,
- /// Look up a namespace name within a C++ using directive or
- /// namespace alias definition, ignoring non-namespace names (C++
- /// [basic.lookup.udir]p1).
- LookupNamespaceName,
- /// Look up all declarations in a scope with the given name,
- /// including resolved using declarations. This is appropriate
- /// for checking redeclarations for a using declaration.
- LookupUsingDeclName,
- /// Look up an ordinary name that is going to be redeclared as a
- /// name with linkage. This lookup ignores any declarations that
- /// are outside of the current scope unless they have linkage. See
- /// C99 6.2.2p4-5 and C++ [basic.link]p6.
- LookupRedeclarationWithLinkage,
- /// Look up the name of an Objective-C protocol.
- LookupObjCProtocolName
- };
-
- /// \brief Specifies whether (or how) name lookup is being performed for a
- /// redeclaration (vs. a reference).
- enum RedeclarationKind {
- /// \brief The lookup is a reference to this name that is not for the
- /// purpose of redeclaring the name.
- NotForRedeclaration = 0,
- /// \brief The lookup results will be used for redeclaration of a name,
- /// if an entity by that name already exists.
- ForRedeclaration
- };
-
-private:
- bool CppLookupName(LookupResult &R, Scope *S);
-
-public:
- /// \brief Look up a name, looking for a single declaration. Return
- /// null if the results were absent, ambiguous, or overloaded.
- ///
- /// It is preferable to use the elaborated form and explicitly handle
- /// ambiguity and overloaded.
- NamedDecl *LookupSingleName(Scope *S, DeclarationName Name,
- SourceLocation Loc,
- LookupNameKind NameKind,
- RedeclarationKind Redecl
- = NotForRedeclaration);
- bool LookupName(LookupResult &R, Scope *S,
- bool AllowBuiltinCreation = false);
- bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
- bool InUnqualifiedLookup = false);
- bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS,
- bool AllowBuiltinCreation = false,
- bool EnteringContext = false);
- ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc);
-
- void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
- QualType T1, QualType T2,
- UnresolvedSetImpl &Functions);
- DeclContext::lookup_result LookupConstructors(CXXRecordDecl *Class);
- CXXDestructorDecl *LookupDestructor(CXXRecordDecl *Class);
-
- void ArgumentDependentLookup(DeclarationName Name, bool Operator,
- Expr **Args, unsigned NumArgs,
- ADLResult &Functions);
-
- void LookupVisibleDecls(Scope *S, LookupNameKind Kind,
- VisibleDeclConsumer &Consumer);
- void LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind,
- VisibleDeclConsumer &Consumer);
-
- /// \brief The context in which typo-correction occurs.
- ///
- /// The typo-correction context affects which keywords (if any) are
- /// considered when trying to correct for typos.
- enum CorrectTypoContext {
- /// \brief An unknown context, where any keyword might be valid.
- CTC_Unknown,
- /// \brief A context where no keywords are used (e.g. we expect an actual
- /// name).
- CTC_NoKeywords,
- /// \brief A context where we're correcting a type name.
- CTC_Type,
- /// \brief An expression context.
- CTC_Expression,
- /// \brief A type cast, or anything else that can be followed by a '<'.
- CTC_CXXCasts,
- /// \brief A member lookup context.
- CTC_MemberLookup,
- /// \brief The receiver of an Objective-C message send within an
- /// Objective-C method where 'super' is a valid keyword.
- CTC_ObjCMessageReceiver
- };
-
- DeclarationName CorrectTypo(LookupResult &R, Scope *S, CXXScopeSpec *SS,
- DeclContext *MemberContext = 0,
- bool EnteringContext = false,
- CorrectTypoContext CTC = CTC_Unknown,
- const ObjCObjectPointerType *OPT = 0);
-
- void FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs,
- AssociatedNamespaceSet &AssociatedNamespaces,
- AssociatedClassSet &AssociatedClasses);
-
- bool DiagnoseAmbiguousLookup(LookupResult &Result);
- //@}
-
- ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *&Id,
- SourceLocation IdLoc,
- bool TypoCorrection = false);
- NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
- Scope *S, bool ForRedeclaration,
- SourceLocation Loc);
- NamedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
- Scope *S);
- void AddKnownFunctionAttributes(FunctionDecl *FD);
-
- // More parsing and symbol table subroutines.
-
- // Decl attributes - this routine is the top level dispatcher.
- void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
- void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL);
-
- void WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method,
- bool &IncompleteImpl, unsigned DiagID);
- void WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethod,
- ObjCMethodDecl *IntfMethod);
-
- bool isPropertyReadonly(ObjCPropertyDecl *PropertyDecl,
- ObjCInterfaceDecl *IDecl);
-
- /// CheckProtocolMethodDefs - This routine checks unimplemented
- /// methods declared in protocol, and those referenced by it.
- /// \param IDecl - Used for checking for methods which may have been
- /// inherited.
- void CheckProtocolMethodDefs(SourceLocation ImpLoc,
- ObjCProtocolDecl *PDecl,
- bool& IncompleteImpl,
- const llvm::DenseSet<Selector> &InsMap,
- const llvm::DenseSet<Selector> &ClsMap,
- ObjCContainerDecl *CDecl);
-
- /// CheckImplementationIvars - This routine checks if the instance variables
- /// listed in the implelementation match those listed in the interface.
- void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
- ObjCIvarDecl **Fields, unsigned nIvars,
- SourceLocation Loc);
-
- /// ImplMethodsVsClassMethods - This is main routine to warn if any method
- /// remains unimplemented in the class or category @implementation.
- void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,
- ObjCContainerDecl* IDecl,
- bool IncompleteImpl = false);
-
- /// DiagnoseUnimplementedProperties - This routine warns on those properties
- /// which must be implemented by this implementation.
- void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
- ObjCContainerDecl *CDecl,
- const llvm::DenseSet<Selector>& InsMap);
-
- /// DefaultSynthesizeProperties - This routine default synthesizes all
- /// properties which must be synthesized in class's @implementation.
- void DefaultSynthesizeProperties (Scope *S, ObjCImplDecl* IMPDecl,
- ObjCInterfaceDecl *IDecl);
-
- /// CollectImmediateProperties - This routine collects all properties in
- /// the class and its conforming protocols; but not those it its super class.
- void CollectImmediateProperties(ObjCContainerDecl *CDecl,
- llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>& PropMap,
- llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>& SuperPropMap);
-
-
- /// LookupPropertyDecl - Looks up a property in the current class and all
- /// its protocols.
- ObjCPropertyDecl *LookupPropertyDecl(const ObjCContainerDecl *CDecl,
- IdentifierInfo *II);
-
- /// Called by ActOnProperty to handle @property declarations in
- //// class extensions.
- DeclPtrTy HandlePropertyInClassExtension(Scope *S,
- ObjCCategoryDecl *CDecl,
- SourceLocation AtLoc,
- FieldDeclarator &FD,
- Selector GetterSel,
- Selector SetterSel,
- const bool isAssign,
- const bool isReadWrite,
- const unsigned Attributes,
- bool *isOverridingProperty,
- TypeSourceInfo *T,
- tok::ObjCKeywordKind MethodImplKind);
-
- /// Called by ActOnProperty and HandlePropertyInClassExtension to
- /// handle creating the ObjcPropertyDecl for a category or @interface.
- ObjCPropertyDecl *CreatePropertyDecl(Scope *S,
- ObjCContainerDecl *CDecl,
- SourceLocation AtLoc,
- FieldDeclarator &FD,
- Selector GetterSel,
- Selector SetterSel,
- const bool isAssign,
- const bool isReadWrite,
- const unsigned Attributes,
- TypeSourceInfo *T,
- tok::ObjCKeywordKind MethodImplKind,
- DeclContext *lexicalDC = 0);
-
- /// AtomicPropertySetterGetterRules - This routine enforces the rule (via
- /// warning) when atomic property has one but not the other user-declared
- /// setter or getter.
- void AtomicPropertySetterGetterRules(ObjCImplDecl* IMPDecl,
- ObjCContainerDecl* IDecl);
-
- void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID);
-
- /// MatchTwoMethodDeclarations - Checks if two methods' type match and returns
- /// true, or false, accordingly.
- bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
- const ObjCMethodDecl *PrevMethod,
- bool matchBasedOnSizeAndAlignment = false,
- bool matchBasedOnStrictEqulity = false);
-
- /// MatchAllMethodDeclarations - Check methods declaraed in interface or
- /// or protocol against those declared in their implementations.
- void MatchAllMethodDeclarations(const llvm::DenseSet<Selector> &InsMap,
- const llvm::DenseSet<Selector> &ClsMap,
- llvm::DenseSet<Selector> &InsMapSeen,
- llvm::DenseSet<Selector> &ClsMapSeen,
- ObjCImplDecl* IMPDecl,
- ObjCContainerDecl* IDecl,
- bool &IncompleteImpl,
- bool ImmediateClass);
-
-private:
- /// AddMethodToGlobalPool - Add an instance or factory method to the global
- /// pool. See descriptoin of AddInstanceMethodToGlobalPool.
- void AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl, bool instance);
-
- /// LookupMethodInGlobalPool - Returns the instance or factory method and
- /// optionally warns if there are multiple signatures.
- ObjCMethodDecl *LookupMethodInGlobalPool(Selector Sel, SourceRange R,
- bool receiverIdOrClass,
- bool warn, bool instance);
-
-public:
- /// AddInstanceMethodToGlobalPool - All instance methods in a translation
- /// unit are added to a global pool. This allows us to efficiently associate
- /// a selector with a method declaraation for purposes of typechecking
- /// messages sent to "id" (where the class of the object is unknown).
- void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) {
- AddMethodToGlobalPool(Method, impl, /*instance*/true);
- }
-
- /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
- void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) {
- AddMethodToGlobalPool(Method, impl, /*instance*/false);
- }
-
- /// LookupInstanceMethodInGlobalPool - Returns the method and warns if
- /// there are multiple signatures.
- ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R,
- bool receiverIdOrClass=false,
- bool warn=true) {
- return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
- warn, /*instance*/true);
- }
-
- /// LookupFactoryMethodInGlobalPool - Returns the method and warns if
- /// there are multiple signatures.
- ObjCMethodDecl *LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R,
- bool receiverIdOrClass=false,
- bool warn=true) {
- return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
- warn, /*instance*/false);
- }
-
- /// LookupImplementedMethodInGlobalPool - Returns the method which has an
- /// implementation.
- ObjCMethodDecl *LookupImplementedMethodInGlobalPool(Selector Sel);
-
- /// CollectIvarsToConstructOrDestruct - Collect those ivars which require
- /// initialization.
- void CollectIvarsToConstructOrDestruct(const ObjCInterfaceDecl *OI,
- llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars);
- //===--------------------------------------------------------------------===//
- // Statement Parsing Callbacks: SemaStmt.cpp.
-public:
- virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr);
-
- virtual OwningStmtResult ActOnNullStmt(SourceLocation SemiLoc);
- virtual OwningStmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
- MultiStmtArg Elts,
- bool isStmtExpr);
- virtual OwningStmtResult ActOnDeclStmt(DeclGroupPtrTy Decl,
- SourceLocation StartLoc,
- SourceLocation EndLoc);
- virtual void ActOnForEachDeclStmt(DeclGroupPtrTy Decl);
- virtual OwningStmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprArg LHSVal,
- SourceLocation DotDotDotLoc, ExprArg RHSVal,
- SourceLocation ColonLoc);
- virtual void ActOnCaseStmtBody(StmtTy *CaseStmt, StmtArg SubStmt);
-
- virtual OwningStmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
- SourceLocation ColonLoc,
- StmtArg SubStmt, Scope *CurScope);
- virtual OwningStmtResult ActOnLabelStmt(SourceLocation IdentLoc,
- IdentifierInfo *II,
- SourceLocation ColonLoc,
- StmtArg SubStmt);
- virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc,
- FullExprArg CondVal, DeclPtrTy CondVar,
- StmtArg ThenVal,
- SourceLocation ElseLoc, StmtArg ElseVal);
- virtual OwningStmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc,
- ExprArg Cond,
- DeclPtrTy CondVar);
- virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
- StmtArg Switch, StmtArg Body);
- virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc,
- FullExprArg Cond,
- DeclPtrTy CondVar, StmtArg Body);
- virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
- SourceLocation WhileLoc,
- SourceLocation CondLParen, ExprArg Cond,
- SourceLocation CondRParen);
-
- virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc,
- SourceLocation LParenLoc,
- StmtArg First, FullExprArg Second,
- DeclPtrTy SecondVar,
- FullExprArg Third,
- SourceLocation RParenLoc,
- StmtArg Body);
- virtual OwningStmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
- SourceLocation LParenLoc,
- StmtArg First, ExprArg Second,
- SourceLocation RParenLoc, StmtArg Body);
-
- virtual OwningStmtResult ActOnGotoStmt(SourceLocation GotoLoc,
- SourceLocation LabelLoc,
- IdentifierInfo *LabelII);
- virtual OwningStmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
- SourceLocation StarLoc,
- ExprArg DestExp);
- virtual OwningStmtResult ActOnContinueStmt(SourceLocation ContinueLoc,
- Scope *CurScope);
- virtual OwningStmtResult ActOnBreakStmt(SourceLocation GotoLoc,
- Scope *CurScope);
-
- virtual OwningStmtResult ActOnReturnStmt(SourceLocation ReturnLoc,
- ExprArg RetValExp);
- OwningStmtResult ActOnBlockReturnStmt(SourceLocation ReturnLoc,
- Expr *RetValExp);
-
- virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc,
- bool IsSimple,
- bool IsVolatile,
- unsigned NumOutputs,
- unsigned NumInputs,
- IdentifierInfo **Names,
- MultiExprArg Constraints,
- MultiExprArg Exprs,
- ExprArg AsmString,
- MultiExprArg Clobbers,
- SourceLocation RParenLoc,
- bool MSAsm = false);
-
-
- VarDecl *BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType,
- IdentifierInfo *Name, SourceLocation NameLoc,
- bool Invalid = false);
-
- virtual DeclPtrTy ActOnObjCExceptionDecl(Scope *S, Declarator &D);
-
- virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
- SourceLocation RParen,
- DeclPtrTy Parm, StmtArg Body);
-
- virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc,
- StmtArg Body);
-
- virtual OwningStmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc,
- StmtArg Try,
- MultiStmtArg Catch,
- StmtArg Finally);
-
- virtual OwningStmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc,
- ExprArg Throw);
- virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc,
- ExprArg Throw,
- Scope *CurScope);
- virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
- ExprArg SynchExpr,
- StmtArg SynchBody);
-
- VarDecl *BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
- TypeSourceInfo *TInfo,
- IdentifierInfo *Name,
- SourceLocation Loc,
- SourceRange Range);
- virtual DeclPtrTy ActOnExceptionDeclarator(Scope *S, Declarator &D);
-
- virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
- DeclPtrTy ExDecl,
- StmtArg HandlerBlock);
- virtual OwningStmtResult ActOnCXXTryBlock(SourceLocation TryLoc,
- StmtArg TryBlock,
- MultiStmtArg Handlers);
- void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock);
-
- /// DiagnoseUnusedExprResult - If the statement passed in is an expression
- /// whose result is unused, warn.
- void DiagnoseUnusedExprResult(const Stmt *S);
- void DiagnoseUnusedDecl(const NamedDecl *ND);
-
- ParsingDeclStackState PushParsingDeclaration();
- void PopParsingDeclaration(ParsingDeclStackState S, DeclPtrTy D);
- void EmitDeprecationWarning(NamedDecl *D, SourceLocation Loc);
-
- void HandleDelayedDeprecationCheck(DelayedDiagnostic &DD, Decl *Ctx);
-
- //===--------------------------------------------------------------------===//
- // Expression Parsing Callbacks: SemaExpr.cpp.
-
- bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc);
- bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD,
- ObjCMethodDecl *Getter,
- SourceLocation Loc);
- void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
- Expr **Args, unsigned NumArgs);
-
- virtual void
- PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext);
-
- virtual void PopExpressionEvaluationContext();
-
- void MarkDeclarationReferenced(SourceLocation Loc, Decl *D);
- void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T);
- bool DiagRuntimeBehavior(SourceLocation Loc, const PartialDiagnostic &PD);
-
- // Primary Expressions.
- virtual SourceRange getExprRange(ExprTy *E) const;
-
- virtual OwningExprResult ActOnIdExpression(Scope *S,
- CXXScopeSpec &SS,
- UnqualifiedId &Name,
- bool HasTrailingLParen,
- bool IsAddressOfOperand);
-
- bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
- CorrectTypoContext CTC = CTC_Unknown);
-
- OwningExprResult LookupInObjCMethod(LookupResult &R,
- Scope *S,
- IdentifierInfo *II,
- bool AllowBuiltinCreation=false);
-
- OwningExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS,
- const DeclarationNameInfo &NameInfo,
- bool isAddressOfOperand,
- const TemplateArgumentListInfo *TemplateArgs);
-
- OwningExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty,
- SourceLocation Loc,
- const CXXScopeSpec *SS = 0);
- OwningExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty,
- const DeclarationNameInfo &NameInfo,
- const CXXScopeSpec *SS = 0);
- VarDecl *BuildAnonymousStructUnionMemberPath(FieldDecl *Field,
- llvm::SmallVectorImpl<FieldDecl *> &Path);
- OwningExprResult
- BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
- FieldDecl *Field,
- Expr *BaseObjectExpr = 0,
- SourceLocation OpLoc = SourceLocation());
- OwningExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS,
- LookupResult &R,
- const TemplateArgumentListInfo *TemplateArgs);
- OwningExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS,
- LookupResult &R,
- const TemplateArgumentListInfo *TemplateArgs,
- bool IsDefiniteInstance);
- bool UseArgumentDependentLookup(const CXXScopeSpec &SS,
- const LookupResult &R,
- bool HasTrailingLParen);
-
- OwningExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
- const DeclarationNameInfo &NameInfo);
- OwningExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS,
- const DeclarationNameInfo &NameInfo,
- const TemplateArgumentListInfo *TemplateArgs);
-
- OwningExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS,
- LookupResult &R,
- bool ADL);
- OwningExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS,
- const DeclarationNameInfo &NameInfo,
- NamedDecl *D);
-
- virtual OwningExprResult ActOnPredefinedExpr(SourceLocation Loc,
- tok::TokenKind Kind);
- virtual OwningExprResult ActOnNumericConstant(const Token &);
- virtual OwningExprResult ActOnCharacterConstant(const Token &);
- virtual OwningExprResult ActOnParenExpr(SourceLocation L, SourceLocation R,
- ExprArg Val);
- virtual OwningExprResult ActOnParenOrParenListExpr(SourceLocation L,
- SourceLocation R,
- MultiExprArg Val,
- TypeTy *TypeOfCast=0);
-
- /// ActOnStringLiteral - The specified tokens were lexed as pasted string
- /// fragments (e.g. "foo" "bar" L"baz").
- virtual OwningExprResult ActOnStringLiteral(const Token *Toks,
- unsigned NumToks);
-
- // Binary/Unary Operators. 'Tok' is the token for the operator.
- OwningExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc,
- unsigned OpcIn,
- ExprArg InputArg);
- OwningExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc,
- UnaryOperator::Opcode Opc, ExprArg input);
- virtual OwningExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
- tok::TokenKind Op, ExprArg Input);
-
- OwningExprResult CreateSizeOfAlignOfExpr(TypeSourceInfo *T,
- SourceLocation OpLoc,
- bool isSizeOf, SourceRange R);
- OwningExprResult CreateSizeOfAlignOfExpr(Expr *E, SourceLocation OpLoc,
- bool isSizeOf, SourceRange R);
- virtual OwningExprResult
- ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType,
- void *TyOrEx, const SourceRange &ArgRange);
-
- bool CheckAlignOfExpr(Expr *E, SourceLocation OpLoc, const SourceRange &R);
- bool CheckSizeOfAlignOfOperand(QualType type, SourceLocation OpLoc,
- const SourceRange &R, bool isSizeof);
-
- virtual OwningExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
- tok::TokenKind Kind,
- ExprArg Input);
-
- virtual OwningExprResult ActOnArraySubscriptExpr(Scope *S, ExprArg Base,
- SourceLocation LLoc,
- ExprArg Idx,
- SourceLocation RLoc);
- OwningExprResult CreateBuiltinArraySubscriptExpr(ExprArg Base,
- SourceLocation LLoc,
- ExprArg Idx,
- SourceLocation RLoc);
-
- OwningExprResult BuildMemberReferenceExpr(ExprArg Base,
- QualType BaseType,
- SourceLocation OpLoc,
- bool IsArrow,
- CXXScopeSpec &SS,
- NamedDecl *FirstQualifierInScope,
- const DeclarationNameInfo &NameInfo,
- const TemplateArgumentListInfo *TemplateArgs);
-
- OwningExprResult BuildMemberReferenceExpr(ExprArg Base,
- QualType BaseType,
- SourceLocation OpLoc, bool IsArrow,
- const CXXScopeSpec &SS,
- NamedDecl *FirstQualifierInScope,
- LookupResult &R,
- const TemplateArgumentListInfo *TemplateArgs,
- bool SuppressQualifierCheck = false);
-
- OwningExprResult LookupMemberExpr(LookupResult &R, Expr *&Base,
- bool &IsArrow, SourceLocation OpLoc,
- CXXScopeSpec &SS,
- DeclPtrTy ObjCImpDecl,
- bool HasTemplateArgs);
-
- bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
- const CXXScopeSpec &SS,
- const LookupResult &R);
-
- OwningExprResult ActOnDependentMemberExpr(ExprArg Base,
- QualType BaseType,
- bool IsArrow,
- SourceLocation OpLoc,
- const CXXScopeSpec &SS,
- NamedDecl *FirstQualifierInScope,
- const DeclarationNameInfo &NameInfo,
- const TemplateArgumentListInfo *TemplateArgs);
-
- virtual OwningExprResult ActOnMemberAccessExpr(Scope *S, ExprArg Base,
- SourceLocation OpLoc,
- tok::TokenKind OpKind,
- CXXScopeSpec &SS,
- UnqualifiedId &Member,
- DeclPtrTy ObjCImpDecl,
- bool HasTrailingLParen);
-
- virtual void ActOnDefaultCtorInitializers(DeclPtrTy CDtorDecl);
- bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
- FunctionDecl *FDecl,
- const FunctionProtoType *Proto,
- Expr **Args, unsigned NumArgs,
- SourceLocation RParenLoc);
-
- /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
- /// This provides the location of the left/right parens and a list of comma
- /// locations.
- virtual OwningExprResult ActOnCallExpr(Scope *S, ExprArg Fn,
- SourceLocation LParenLoc,
- MultiExprArg Args,
- SourceLocation *CommaLocs,
- SourceLocation RParenLoc);
- OwningExprResult BuildResolvedCallExpr(Expr *Fn,
- NamedDecl *NDecl,
- SourceLocation LParenLoc,
- Expr **Args, unsigned NumArgs,
- SourceLocation RParenLoc);
-
- virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
- TypeTy *Ty, SourceLocation RParenLoc,
- ExprArg Op);
- OwningExprResult BuildCStyleCastExpr(SourceLocation LParenLoc,
- TypeSourceInfo *Ty,
- SourceLocation RParenLoc,
- ExprArg Op);
-
- virtual bool TypeIsVectorType(TypeTy *Ty) {
- return GetTypeFromParser(Ty)->isVectorType();
- }
-
- OwningExprResult MaybeConvertParenListExprToParenExpr(Scope *S, ExprArg ME);
- OwningExprResult ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc,
- SourceLocation RParenLoc, ExprArg E,
- TypeSourceInfo *TInfo);
-
- virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParenLoc,
- TypeTy *Ty,
- SourceLocation RParenLoc,
- ExprArg Op);
-
- OwningExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc,
- TypeSourceInfo *TInfo,
- SourceLocation RParenLoc,
- ExprArg InitExpr);
-
- virtual OwningExprResult ActOnInitList(SourceLocation LParenLoc,
- MultiExprArg InitList,
- SourceLocation RParenLoc);
-
- virtual OwningExprResult ActOnDesignatedInitializer(Designation &Desig,
- SourceLocation Loc,
- bool GNUSyntax,
- OwningExprResult Init);
-
- virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
- tok::TokenKind Kind,
- ExprArg LHS, ExprArg RHS);
- OwningExprResult BuildBinOp(Scope *S, SourceLocation OpLoc,
- BinaryOperator::Opcode Opc,
- Expr *lhs, Expr *rhs);
- OwningExprResult CreateBuiltinBinOp(SourceLocation TokLoc,
- unsigned Opc, Expr *lhs, Expr *rhs);
-
- /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
- /// in the case of a the GNU conditional expr extension.
- virtual OwningExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
- SourceLocation ColonLoc,
- ExprArg Cond, ExprArg LHS,
- ExprArg RHS);
-
- /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
- virtual OwningExprResult ActOnAddrLabel(SourceLocation OpLoc,
- SourceLocation LabLoc,
- IdentifierInfo *LabelII);
-
- virtual OwningExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtArg SubStmt,
- SourceLocation RPLoc); // "({..})"
-
- /// __builtin_offsetof(type, a.b[123][456].c)
- OwningExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
- TypeSourceInfo *TInfo,
- OffsetOfComponent *CompPtr,
- unsigned NumComponents,
- SourceLocation RParenLoc);
- virtual OwningExprResult ActOnBuiltinOffsetOf(Scope *S,
- SourceLocation BuiltinLoc,
- SourceLocation TypeLoc,
- TypeTy *Arg1,
- OffsetOfComponent *CompPtr,
- unsigned NumComponents,
- SourceLocation RParenLoc);
-
- // __builtin_types_compatible_p(type1, type2)
- virtual OwningExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
- TypeTy *arg1, TypeTy *arg2,
- SourceLocation RPLoc);
- OwningExprResult BuildTypesCompatibleExpr(SourceLocation BuiltinLoc,
- TypeSourceInfo *argTInfo1,
- TypeSourceInfo *argTInfo2,
- SourceLocation RPLoc);
-
- // __builtin_choose_expr(constExpr, expr1, expr2)
- virtual OwningExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
- ExprArg cond, ExprArg expr1,
- ExprArg expr2, SourceLocation RPLoc);
-
- // __builtin_va_arg(expr, type)
- virtual OwningExprResult ActOnVAArg(SourceLocation BuiltinLoc,
- ExprArg expr, TypeTy *type,
- SourceLocation RPLoc);
- OwningExprResult BuildVAArgExpr(SourceLocation BuiltinLoc,
- ExprArg expr, TypeSourceInfo *TInfo,
- SourceLocation RPLoc);
-
- // __null
- virtual OwningExprResult ActOnGNUNullExpr(SourceLocation TokenLoc);
-
- //===------------------------- "Block" Extension ------------------------===//
-
- /// ActOnBlockStart - This callback is invoked when a block literal is
- /// started.
- virtual void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
-
- /// ActOnBlockArguments - This callback allows processing of block arguments.
- /// If there are no arguments, this is still invoked.
- virtual void ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope);
-
- /// ActOnBlockError - If there is an error parsing a block, this callback
- /// is invoked to pop the information about the block from the action impl.
- virtual void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
-
- /// ActOnBlockStmtExpr - This is called when the body of a block statement
- /// literal was successfully completed. ^(int x){...}
- virtual OwningExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc,
- StmtArg Body, Scope *CurScope);
-
- //===---------------------------- C++ Features --------------------------===//
-
- // Act on C++ namespaces
- virtual DeclPtrTy ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc,
- IdentifierInfo *Ident,
- SourceLocation LBrace,
- AttributeList *AttrList);
- virtual void ActOnFinishNamespaceDef(DeclPtrTy Dcl, SourceLocation RBrace);
-
- NamespaceDecl *getStdNamespace() const {
- return cast_or_null<NamespaceDecl>(
- StdNamespace.get(Context.getExternalSource()));
- }
- NamespaceDecl *getOrCreateStdNamespace();
-
- CXXRecordDecl *getStdBadAlloc() const {
- return cast_or_null<CXXRecordDecl>(
- StdBadAlloc.get(Context.getExternalSource()));
- }
-
- virtual DeclPtrTy ActOnUsingDirective(Scope *CurScope,
- SourceLocation UsingLoc,
- SourceLocation NamespcLoc,
- CXXScopeSpec &SS,
- SourceLocation IdentLoc,
- IdentifierInfo *NamespcName,
- AttributeList *AttrList);
-
- void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir);
-
- virtual DeclPtrTy ActOnNamespaceAliasDef(Scope *CurScope,
- SourceLocation NamespaceLoc,
- SourceLocation AliasLoc,
- IdentifierInfo *Alias,
- CXXScopeSpec &SS,
- SourceLocation IdentLoc,
- IdentifierInfo *Ident);
-
- void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
- bool CheckUsingShadowDecl(UsingDecl *UD, NamedDecl *Target,
- const LookupResult &PreviousDecls);
- UsingShadowDecl *BuildUsingShadowDecl(Scope *S, UsingDecl *UD,
- NamedDecl *Target);
-
- bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc,
- bool isTypeName,
- const CXXScopeSpec &SS,
- SourceLocation NameLoc,
- const LookupResult &Previous);
- bool CheckUsingDeclQualifier(SourceLocation UsingLoc,
- const CXXScopeSpec &SS,
- SourceLocation NameLoc);
-
- NamedDecl *BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
- SourceLocation UsingLoc,
- CXXScopeSpec &SS,
- const DeclarationNameInfo &NameInfo,
- AttributeList *AttrList,
- bool IsInstantiation,
- bool IsTypeName,
- SourceLocation TypenameLoc);
-
- virtual DeclPtrTy ActOnUsingDeclaration(Scope *CurScope,
- AccessSpecifier AS,
- bool HasUsingKeyword,
- SourceLocation UsingLoc,
- CXXScopeSpec &SS,
- UnqualifiedId &Name,
- AttributeList *AttrList,
- bool IsTypeName,
- SourceLocation TypenameLoc);
-
- /// AddCXXDirectInitializerToDecl - This action is called immediately after
- /// ActOnDeclarator, when a C++ direct initializer is present.
- /// e.g: "int x(1);"
- virtual void AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
- SourceLocation LParenLoc,
- MultiExprArg Exprs,
- SourceLocation *CommaLocs,
- SourceLocation RParenLoc);
-
- /// InitializeVarWithConstructor - Creates an CXXConstructExpr
- /// and sets it as the initializer for the the passed in VarDecl.
- bool InitializeVarWithConstructor(VarDecl *VD,
- CXXConstructorDecl *Constructor,
- MultiExprArg Exprs);
-
- /// BuildCXXConstructExpr - Creates a complete call to a constructor,
- /// including handling of its default argument expressions.
- OwningExprResult
- BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
- CXXConstructorDecl *Constructor, MultiExprArg Exprs,
- bool RequiresZeroInit = false,
- CXXConstructExpr::ConstructionKind ConstructKind =
- CXXConstructExpr::CK_Complete);
-
- // FIXME: Can re remove this and have the above BuildCXXConstructExpr check if
- // the constructor can be elidable?
- OwningExprResult
- BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
- CXXConstructorDecl *Constructor, bool Elidable,
- MultiExprArg Exprs, bool RequiresZeroInit = false,
- CXXConstructExpr::ConstructionKind ConstructKind =
- CXXConstructExpr::CK_Complete);
-
- /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
- /// the default expr if needed.
- OwningExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc,
- FunctionDecl *FD,
- ParmVarDecl *Param);
-
- /// FinalizeVarWithDestructor - Prepare for calling destructor on the
- /// constructed variable.
- void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType);
-
- /// \brief Declare the implicit default constructor for the given class.
- ///
- /// \param ClassDecl The class declaration into which the implicit
- /// default constructor will be added.
- ///
- /// \returns The implicitly-declared default constructor.
- CXXConstructorDecl *DeclareImplicitDefaultConstructor(
- CXXRecordDecl *ClassDecl);
-
- /// DefineImplicitDefaultConstructor - Checks for feasibility of
- /// defining this constructor as the default constructor.
- void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
- CXXConstructorDecl *Constructor);
-
- /// \brief Declare the implicit destructor for the given class.
- ///
- /// \param ClassDecl The class declaration into which the implicit
- /// destructor will be added.
- ///
- /// \returns The implicitly-declared destructor.
- CXXDestructorDecl *DeclareImplicitDestructor(CXXRecordDecl *ClassDecl);
-
- /// DefineImplicitDestructor - Checks for feasibility of
- /// defining this destructor as the default destructor.
- void DefineImplicitDestructor(SourceLocation CurrentLocation,
- CXXDestructorDecl *Destructor);
-
- /// \brief Declare the implicit copy constructor for the given class.
- ///
- /// \param S The scope of the class, which may be NULL if this is a
- /// template instantiation.
- ///
- /// \param ClassDecl The class declaration into which the implicit
- /// copy constructor will be added.
- ///
- /// \returns The implicitly-declared copy constructor.
- CXXConstructorDecl *DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl);
-
- /// DefineImplicitCopyConstructor - Checks for feasibility of
- /// defining this constructor as the copy constructor.
- void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
- CXXConstructorDecl *Constructor,
- unsigned TypeQuals);
-
- /// \brief Declare the implicit copy assignment operator for the given class.
- ///
- /// \param S The scope of the class, which may be NULL if this is a
- /// template instantiation.
- ///
- /// \param ClassDecl The class declaration into which the implicit
- /// copy-assignment operator will be added.
- ///
- /// \returns The implicitly-declared copy assignment operator.
- CXXMethodDecl *DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl);
-
- /// \brief Defined an implicitly-declared copy assignment operator.
- void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
- CXXMethodDecl *MethodDecl);
-
- /// \brief Force the declaration of any implicitly-declared members of this
- /// class.
- void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class);
-
- /// MaybeBindToTemporary - If the passed in expression has a record type with
- /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
- /// it simply returns the passed in expression.
- OwningExprResult MaybeBindToTemporary(Expr *E);
-
- bool CompleteConstructorCall(CXXConstructorDecl *Constructor,
- MultiExprArg ArgsPtr,
- SourceLocation Loc,
- ASTOwningVector<&ActionBase::DeleteExpr> &ConvertedArgs);
-
- virtual TypeTy *getDestructorName(SourceLocation TildeLoc,
- IdentifierInfo &II, SourceLocation NameLoc,
- Scope *S, CXXScopeSpec &SS,
- TypeTy *ObjectType,
- bool EnteringContext);
-
- /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's.
- virtual OwningExprResult ActOnCXXNamedCast(SourceLocation OpLoc,
- tok::TokenKind Kind,
- SourceLocation LAngleBracketLoc,
- TypeTy *Ty,
- SourceLocation RAngleBracketLoc,
- SourceLocation LParenLoc,
- ExprArg E,
- SourceLocation RParenLoc);
-
- OwningExprResult BuildCXXNamedCast(SourceLocation OpLoc,
- tok::TokenKind Kind,
- TypeSourceInfo *Ty,
- ExprArg E,
- SourceRange AngleBrackets,
- SourceRange Parens);
-
- OwningExprResult BuildCXXTypeId(QualType TypeInfoType,
- SourceLocation TypeidLoc,
- TypeSourceInfo *Operand,
- SourceLocation RParenLoc);
- OwningExprResult BuildCXXTypeId(QualType TypeInfoType,
- SourceLocation TypeidLoc,
- ExprArg Operand,
- SourceLocation RParenLoc);
-
- /// ActOnCXXTypeid - Parse typeid( something ).
- virtual OwningExprResult ActOnCXXTypeid(SourceLocation OpLoc,
- SourceLocation LParenLoc, bool isType,
- void *TyOrExpr,
- SourceLocation RParenLoc);
-
- //// ActOnCXXThis - Parse 'this' pointer.
- virtual OwningExprResult ActOnCXXThis(SourceLocation ThisLoc);
-
- /// ActOnCXXBoolLiteral - Parse {true,false} literals.
- virtual OwningExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc,
- tok::TokenKind Kind);
-
- /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
- virtual OwningExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc);
-
- //// ActOnCXXThrow - Parse throw expressions.
- virtual OwningExprResult ActOnCXXThrow(SourceLocation OpLoc,
- ExprArg expr);
- bool CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E);
-
- /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
- /// Can be interpreted either as function-style casting ("int(x)")
- /// or class type construction ("ClassType(x,y,z)")
- /// or creation of a value-initialized type ("int()").
- virtual OwningExprResult ActOnCXXTypeConstructExpr(SourceRange TypeRange,
- TypeTy *TypeRep,
- SourceLocation LParenLoc,
- MultiExprArg Exprs,
- SourceLocation *CommaLocs,
- SourceLocation RParenLoc);
-
- /// ActOnCXXNew - Parsed a C++ 'new' expression.
- virtual OwningExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
- SourceLocation PlacementLParen,
- MultiExprArg PlacementArgs,
- SourceLocation PlacementRParen,
- SourceRange TypeIdParens, Declarator &D,
- SourceLocation ConstructorLParen,
- MultiExprArg ConstructorArgs,
- SourceLocation ConstructorRParen);
- OwningExprResult BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
- SourceLocation PlacementLParen,
- MultiExprArg PlacementArgs,
- SourceLocation PlacementRParen,
- SourceRange TypeIdParens,
- QualType AllocType,
- SourceLocation TypeLoc,
- SourceRange TypeRange,
- ExprArg ArraySize,
- SourceLocation ConstructorLParen,
- MultiExprArg ConstructorArgs,
- SourceLocation ConstructorRParen);
-
- bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
- SourceRange R);
- bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
- bool UseGlobal, QualType AllocType, bool IsArray,
- Expr **PlaceArgs, unsigned NumPlaceArgs,
- FunctionDecl *&OperatorNew,
- FunctionDecl *&OperatorDelete);
- bool FindAllocationOverload(SourceLocation StartLoc, SourceRange Range,
- DeclarationName Name, Expr** Args,
- unsigned NumArgs, DeclContext *Ctx,
- bool AllowMissing, FunctionDecl *&Operator);
- void DeclareGlobalNewDelete();
- void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return,
- QualType Argument,
- bool addMallocAttr = false);
-
- bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD,
- DeclarationName Name, FunctionDecl* &Operator);
-
- /// ActOnCXXDelete - Parsed a C++ 'delete' expression
- virtual OwningExprResult ActOnCXXDelete(SourceLocation StartLoc,
- bool UseGlobal, bool ArrayForm,
- ExprArg Operand);
-
- virtual DeclResult ActOnCXXConditionDeclaration(Scope *S,
- Declarator &D);
- OwningExprResult CheckConditionVariable(VarDecl *ConditionVar,
- SourceLocation StmtLoc,
- bool ConvertToBoolean);
-
- /// ActOnUnaryTypeTrait - Parsed one of the unary type trait support
- /// pseudo-functions.
- virtual OwningExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT,
- SourceLocation KWLoc,
- SourceLocation LParen,
- TypeTy *Ty,
- SourceLocation RParen);
-
- virtual OwningExprResult ActOnStartCXXMemberReference(Scope *S,
- ExprArg Base,
- SourceLocation OpLoc,
- tok::TokenKind OpKind,
- TypeTy *&ObjectType,
- bool &MayBePseudoDestructor);
-
- OwningExprResult DiagnoseDtorReference(SourceLocation NameLoc,
- ExprArg MemExpr);
-
- OwningExprResult BuildPseudoDestructorExpr(ExprArg Base,
- SourceLocation OpLoc,
- tok::TokenKind OpKind,
- const CXXScopeSpec &SS,
- TypeSourceInfo *ScopeType,
- SourceLocation CCLoc,
- SourceLocation TildeLoc,
- PseudoDestructorTypeStorage DestroyedType,
- bool HasTrailingLParen);
-
- virtual OwningExprResult ActOnPseudoDestructorExpr(Scope *S, ExprArg Base,
- SourceLocation OpLoc,
- tok::TokenKind OpKind,
- CXXScopeSpec &SS,
- UnqualifiedId &FirstTypeName,
- SourceLocation CCLoc,
- SourceLocation TildeLoc,
- UnqualifiedId &SecondTypeName,
- bool HasTrailingLParen);
-
- /// MaybeCreateCXXExprWithTemporaries - If the list of temporaries is
- /// non-empty, will create a new CXXExprWithTemporaries expression.
- /// Otherwise, just returs the passed in expression.
- Expr *MaybeCreateCXXExprWithTemporaries(Expr *SubExpr);
- OwningExprResult MaybeCreateCXXExprWithTemporaries(OwningExprResult SubExpr);
- FullExpr CreateFullExpr(Expr *SubExpr);
-
- virtual OwningExprResult ActOnFinishFullExpr(ExprArg Expr);
-
- // Marks SS invalid if it represents an incomplete type.
- bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC);
-
- DeclContext *computeDeclContext(QualType T);
- DeclContext *computeDeclContext(const CXXScopeSpec &SS,
- bool EnteringContext = false);
- bool isDependentScopeSpecifier(const CXXScopeSpec &SS);
- CXXRecordDecl *getCurrentInstantiationOf(NestedNameSpecifier *NNS);
- bool isUnknownSpecialization(const CXXScopeSpec &SS);
-
- /// ActOnCXXGlobalScopeSpecifier - Return the object that represents the
- /// global scope ('::').
- virtual CXXScopeTy *ActOnCXXGlobalScopeSpecifier(Scope *S,
- SourceLocation CCLoc);
-
- bool isAcceptableNestedNameSpecifier(NamedDecl *SD);
- NamedDecl *FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS);
-
- virtual bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
- SourceLocation IdLoc,
- IdentifierInfo &II,
- TypeTy *ObjectType);
-
- CXXScopeTy *BuildCXXNestedNameSpecifier(Scope *S,
- CXXScopeSpec &SS,
- SourceLocation IdLoc,
- SourceLocation CCLoc,
- IdentifierInfo &II,
- QualType ObjectType,
- NamedDecl *ScopeLookupResult,
- bool EnteringContext,
- bool ErrorRecoveryLookup);
-
- virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S,
- CXXScopeSpec &SS,
- SourceLocation IdLoc,
- SourceLocation CCLoc,
- IdentifierInfo &II,
- TypeTy *ObjectType,
- bool EnteringContext);
-
- virtual bool IsInvalidUnlessNestedName(Scope *S,
- CXXScopeSpec &SS,
- IdentifierInfo &II,
- TypeTy *ObjectType,
- bool EnteringContext);
-
- /// ActOnCXXNestedNameSpecifier - Called during parsing of a
- /// nested-name-specifier that involves a template-id, e.g.,
- /// "foo::bar<int, float>::", and now we need to build a scope
- /// specifier. \p SS is empty or the previously parsed nested-name
- /// part ("foo::"), \p Type is the already-parsed class template
- /// specialization (or other template-id that names a type), \p
- /// TypeRange is the source range where the type is located, and \p
- /// CCLoc is the location of the trailing '::'.
- virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S,
- const CXXScopeSpec &SS,
- TypeTy *Type,
- SourceRange TypeRange,
- SourceLocation CCLoc);
-
- virtual bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
-
- /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
- /// scope or nested-name-specifier) is parsed, part of a declarator-id.
- /// After this method is called, according to [C++ 3.4.3p3], names should be
- /// looked up in the declarator-id's scope, until the declarator is parsed and
- /// ActOnCXXExitDeclaratorScope is called.
- /// The 'SS' should be a non-empty valid CXXScopeSpec.
- virtual bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS);
-
- /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
- /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
- /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
- /// Used to indicate that names should revert to being looked up in the
- /// defining scope.
- virtual void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
-
- /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
- /// initializer for the declaration 'Dcl'.
- /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
- /// static data member of class X, names should be looked up in the scope of
- /// class X.
- virtual void ActOnCXXEnterDeclInitializer(Scope *S, DeclPtrTy Dcl);
-
- /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
- /// initializer for the declaration 'Dcl'.
- virtual void ActOnCXXExitDeclInitializer(Scope *S, DeclPtrTy Dcl);
-
- // ParseObjCStringLiteral - Parse Objective-C string literals.
- virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
- ExprTy **Strings,
- unsigned NumStrings);
-
- Expr *BuildObjCEncodeExpression(SourceLocation AtLoc,
- TypeSourceInfo *EncodedTypeInfo,
- SourceLocation RParenLoc);
- CXXMemberCallExpr *BuildCXXMemberCallExpr(Expr *Exp,
- NamedDecl *FoundDecl,
- CXXMethodDecl *Method);
-
- virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
- SourceLocation EncodeLoc,
- SourceLocation LParenLoc,
- TypeTy *Ty,
- SourceLocation RParenLoc);
-
- // ParseObjCSelectorExpression - Build selector expression for @selector
- virtual ExprResult ParseObjCSelectorExpression(Selector Sel,
- SourceLocation AtLoc,
- SourceLocation SelLoc,
- SourceLocation LParenLoc,
- SourceLocation RParenLoc);
-
- // ParseObjCProtocolExpression - Build protocol expression for @protocol
- virtual ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName,
- SourceLocation AtLoc,
- SourceLocation ProtoLoc,
- SourceLocation LParenLoc,
- SourceLocation RParenLoc);
-
- //===--------------------------------------------------------------------===//
- // C++ Declarations
- //
- virtual DeclPtrTy ActOnStartLinkageSpecification(Scope *S,
- SourceLocation ExternLoc,
- SourceLocation LangLoc,
- llvm::StringRef Lang,
- SourceLocation LBraceLoc);
- virtual DeclPtrTy ActOnFinishLinkageSpecification(Scope *S,
- DeclPtrTy LinkageSpec,
- SourceLocation RBraceLoc);
-
-
- //===--------------------------------------------------------------------===//
- // C++ Classes
- //
- virtual bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
- const CXXScopeSpec *SS);
-
- virtual DeclPtrTy ActOnAccessSpecifier(AccessSpecifier Access,
- SourceLocation ASLoc,
- SourceLocation ColonLoc);
-
- virtual DeclPtrTy ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS,
- Declarator &D,
- MultiTemplateParamsArg TemplateParameterLists,
- ExprTy *BitfieldWidth,
- ExprTy *Init, bool IsDefinition,
- bool Deleted = false);
-
- virtual MemInitResult ActOnMemInitializer(DeclPtrTy ConstructorD,
- Scope *S,
- CXXScopeSpec &SS,
- IdentifierInfo *MemberOrBase,
- TypeTy *TemplateTypeTy,
- SourceLocation IdLoc,
- SourceLocation LParenLoc,
- ExprTy **Args, unsigned NumArgs,
- SourceLocation *CommaLocs,
- SourceLocation RParenLoc);
-
- MemInitResult BuildMemberInitializer(FieldDecl *Member, Expr **Args,
- unsigned NumArgs, SourceLocation IdLoc,
- SourceLocation LParenLoc,
- SourceLocation RParenLoc);
-
- MemInitResult BuildBaseInitializer(QualType BaseType,
- TypeSourceInfo *BaseTInfo,
- Expr **Args, unsigned NumArgs,
- SourceLocation LParenLoc,
- SourceLocation RParenLoc,
- CXXRecordDecl *ClassDecl);
-
- bool SetBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
- CXXBaseOrMemberInitializer **Initializers,
- unsigned NumInitializers, bool AnyErrors);
-
- void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation);
-
-
- /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
- /// mark all the non-trivial destructors of its members and bases as
- /// referenced.
- void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
- CXXRecordDecl *Record);
-
- /// \brief The list of classes whose vtables have been used within
- /// this translation unit, and the source locations at which the
- /// first use occurred.
- llvm::SmallVector<std::pair<CXXRecordDecl *, SourceLocation>, 16>
- VTableUses;
-
- /// \brief The set of classes whose vtables have been used within
- /// this translation unit, and a bit that will be true if the vtable is
- /// required to be emitted (otherwise, it should be emitted only if needed
- /// by code generation).
- llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
-
- /// \brief A list of all of the dynamic classes in this translation
- /// unit.
- llvm::SmallVector<CXXRecordDecl *, 16> DynamicClasses;
-
- /// \brief Note that the vtable for the given class was used at the
- /// given location.
- void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class,
- bool DefinitionRequired = false);
-
- /// MarkVirtualMembersReferenced - Will mark all virtual members of the given
- /// CXXRecordDecl referenced.
- void MarkVirtualMembersReferenced(SourceLocation Loc,
- const CXXRecordDecl *RD);
-
- /// \brief Define all of the vtables that have been used in this
- /// translation unit and reference any virtual members used by those
- /// vtables.
- ///
- /// \returns true if any work was done, false otherwise.
- bool DefineUsedVTables();
-
- void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl);
-
- virtual void ActOnMemInitializers(DeclPtrTy ConstructorDecl,
- SourceLocation ColonLoc,
- MemInitTy **MemInits, unsigned NumMemInits,
- bool AnyErrors);
-
- void CheckCompletedCXXClass(CXXRecordDecl *Record);
- virtual void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
- DeclPtrTy TagDecl,
- SourceLocation LBrac,
- SourceLocation RBrac,
- AttributeList *AttrList);
-
- virtual void ActOnReenterTemplateScope(Scope *S, DeclPtrTy Template);
- virtual void ActOnStartDelayedMemberDeclarations(Scope *S,
- DeclPtrTy Record);
- virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S,
- DeclPtrTy Method);
- virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclPtrTy Param);
- virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S,
- DeclPtrTy Method);
- virtual void ActOnFinishDelayedMemberDeclarations(Scope *S,
- DeclPtrTy Record);
-
- virtual DeclPtrTy ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
- ExprArg AssertExpr,
- ExprArg AssertMessageExpr);
-
- FriendDecl *CheckFriendTypeDecl(SourceLocation FriendLoc,
- TypeSourceInfo *TSInfo);
- DeclPtrTy ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
- MultiTemplateParamsArg TemplateParams);
- DeclPtrTy ActOnFriendFunctionDecl(Scope *S, Declarator &D, bool IsDefinition,
- MultiTemplateParamsArg TemplateParams);
-
- QualType CheckConstructorDeclarator(Declarator &D, QualType R,
- FunctionDecl::StorageClass& SC);
- void CheckConstructor(CXXConstructorDecl *Constructor);
- QualType CheckDestructorDeclarator(Declarator &D, QualType R,
- FunctionDecl::StorageClass& SC);
- bool CheckDestructor(CXXDestructorDecl *Destructor);
- void CheckConversionDeclarator(Declarator &D, QualType &R,
- FunctionDecl::StorageClass& SC);
- DeclPtrTy ActOnConversionDeclarator(CXXConversionDecl *Conversion);
-
- //===--------------------------------------------------------------------===//
- // C++ Derived Classes
- //
-
- /// ActOnBaseSpecifier - Parsed a base specifier
- CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class,
- SourceRange SpecifierRange,
- bool Virtual, AccessSpecifier Access,
- TypeSourceInfo *TInfo);
-
- /// SetClassDeclAttributesFromBase - Copies class decl traits
- /// (such as whether the class has a trivial constructor,
- /// trivial destructor etc) from the given base class.
- void SetClassDeclAttributesFromBase(CXXRecordDecl *Class,
- const CXXRecordDecl *BaseClass,
- bool BaseIsVirtual);
-
- virtual BaseResult ActOnBaseSpecifier(DeclPtrTy classdecl,
- SourceRange SpecifierRange,
- bool Virtual, AccessSpecifier Access,
- TypeTy *basetype, SourceLocation
- BaseLoc);
-
- bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases,
- unsigned NumBases);
- virtual void ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases,
- unsigned NumBases);
-
- bool IsDerivedFrom(QualType Derived, QualType Base);
- bool IsDerivedFrom(QualType Derived, QualType Base, CXXBasePaths &Paths);
-
- // FIXME: I don't like this name.
- void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
-
- bool BasePathInvolvesVirtualBase(const CXXCastPath &BasePath);
-
- bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
- SourceLocation Loc, SourceRange Range,
- CXXCastPath *BasePath = 0,
- bool IgnoreAccess = false);
- bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
- unsigned InaccessibleBaseID,
- unsigned AmbigiousBaseConvID,
- SourceLocation Loc, SourceRange Range,
- DeclarationName Name,
- CXXCastPath *BasePath);
-
- std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
-
- /// CheckOverridingFunctionReturnType - Checks whether the return types are
- /// covariant, according to C++ [class.virtual]p5.
- bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
- const CXXMethodDecl *Old);
-
- /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
- /// spec is a subset of base spec.
- bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
- const CXXMethodDecl *Old);
-
- /// CheckOverridingFunctionAttributes - Checks whether attributes are
- /// incompatible or prevent overriding.
- bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New,
- const CXXMethodDecl *Old);
-
- bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange);
-
- //===--------------------------------------------------------------------===//
- // C++ Access Control
- //
-
- enum AccessResult {
- AR_accessible,
- AR_inaccessible,
- AR_dependent,
- AR_delayed
- };
-
- bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
- NamedDecl *PrevMemberDecl,
- AccessSpecifier LexicalAS);
-
- AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E,
- DeclAccessPair FoundDecl);
- AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E,
- DeclAccessPair FoundDecl);
- AccessResult CheckAllocationAccess(SourceLocation OperatorLoc,
- SourceRange PlacementRange,
- CXXRecordDecl *NamingClass,
- DeclAccessPair FoundDecl);
- AccessResult CheckConstructorAccess(SourceLocation Loc,
- CXXConstructorDecl *D,
- const InitializedEntity &Entity,
- AccessSpecifier Access,
- bool IsCopyBindingRefToTemp = false);
- AccessResult CheckDestructorAccess(SourceLocation Loc,
- CXXDestructorDecl *Dtor,
- const PartialDiagnostic &PDiag);
- AccessResult CheckDirectMemberAccess(SourceLocation Loc,
- NamedDecl *D,
- const PartialDiagnostic &PDiag);
- AccessResult CheckMemberOperatorAccess(SourceLocation Loc,
- Expr *ObjectExpr,
- Expr *ArgExpr,
- DeclAccessPair FoundDecl);
- AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr,
- DeclAccessPair FoundDecl);
- AccessResult CheckBaseClassAccess(SourceLocation AccessLoc,
- QualType Base, QualType Derived,
- const CXXBasePath &Path,
- unsigned DiagID,
- bool ForceCheck = false,
- bool ForceUnprivileged = false);
- void CheckLookupAccess(const LookupResult &R);
-
- void HandleDependentAccessCheck(const DependentDiagnostic &DD,
- const MultiLevelTemplateArgumentList &TemplateArgs);
- void PerformDependentDiagnostics(const DeclContext *Pattern,
- const MultiLevelTemplateArgumentList &TemplateArgs);
-
- void HandleDelayedAccessCheck(DelayedDiagnostic &DD, Decl *Ctx);
-
- /// A flag to suppress access checking.
- bool SuppressAccessChecking;
-
- void ActOnStartSuppressingAccessChecks();
- void ActOnStopSuppressingAccessChecks();
-
- enum AbstractDiagSelID {
- AbstractNone = -1,
- AbstractReturnType,
- AbstractParamType,
- AbstractVariableType,
- AbstractFieldType
- };
-
- bool RequireNonAbstractType(SourceLocation Loc, QualType T,
- const PartialDiagnostic &PD,
- const CXXRecordDecl *CurrentRD = 0);
-
- bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID,
- AbstractDiagSelID SelID = AbstractNone,
- const CXXRecordDecl *CurrentRD = 0);
-
- //===--------------------------------------------------------------------===//
- // C++ Overloaded Operators [C++ 13.5]
- //
-
- bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl);
-
- bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl);
-
- //===--------------------------------------------------------------------===//
- // C++ Templates [C++ 14]
- //
- void LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS,
- QualType ObjectType, bool EnteringContext,
- bool &MemberOfUnknownSpecialization);
-
- virtual TemplateNameKind isTemplateName(Scope *S,
- CXXScopeSpec &SS,
- bool hasTemplateKeyword,
- UnqualifiedId &Name,
- TypeTy *ObjectType,
- bool EnteringContext,
- TemplateTy &Template,
- bool &MemberOfUnknownSpecialization);
-
- virtual bool DiagnoseUnknownTemplateName(const IdentifierInfo &II,
- SourceLocation IILoc,
- Scope *S,
- const CXXScopeSpec *SS,
- TemplateTy &SuggestedTemplate,
- TemplateNameKind &SuggestedKind);
-
- bool DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl);
- TemplateDecl *AdjustDeclIfTemplate(DeclPtrTy &Decl);
-
- virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis,
- SourceLocation EllipsisLoc,
- SourceLocation KeyLoc,
- IdentifierInfo *ParamName,
- SourceLocation ParamNameLoc,
- unsigned Depth, unsigned Position,
- SourceLocation EqualLoc,
- TypeTy *DefaultArg);
-
- QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc);
- virtual DeclPtrTy ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
- unsigned Depth,
- unsigned Position,
- SourceLocation EqualLoc,
- ExprArg DefaultArg);
- virtual DeclPtrTy ActOnTemplateTemplateParameter(Scope *S,
- SourceLocation TmpLoc,
- TemplateParamsTy *Params,
- IdentifierInfo *ParamName,
- SourceLocation ParamNameLoc,
- unsigned Depth,
- unsigned Position,
- SourceLocation EqualLoc,
- const ParsedTemplateArgument &DefaultArg);
-
- virtual TemplateParamsTy *
- ActOnTemplateParameterList(unsigned Depth,
- SourceLocation ExportLoc,
- SourceLocation TemplateLoc,
- SourceLocation LAngleLoc,
- DeclPtrTy *Params, unsigned NumParams,
- SourceLocation RAngleLoc);
-
- /// \brief The context in which we are checking a template parameter
- /// list.
- enum TemplateParamListContext {
- TPC_ClassTemplate,
- TPC_FunctionTemplate,
- TPC_ClassTemplateMember,
- TPC_FriendFunctionTemplate
- };
-
- bool CheckTemplateParameterList(TemplateParameterList *NewParams,
- TemplateParameterList *OldParams,
- TemplateParamListContext TPC);
- TemplateParameterList *
- MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc,
- const CXXScopeSpec &SS,
- TemplateParameterList **ParamLists,
- unsigned NumParamLists,
- bool IsFriend,
- bool &IsExplicitSpecialization,
- bool &Invalid);
-
- DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
- SourceLocation KWLoc, CXXScopeSpec &SS,
- IdentifierInfo *Name, SourceLocation NameLoc,
- AttributeList *Attr,
- TemplateParameterList *TemplateParams,
- AccessSpecifier AS);
-
- void translateTemplateArguments(const ASTTemplateArgsPtr &In,
- TemplateArgumentListInfo &Out);
-
- QualType CheckTemplateIdType(TemplateName Template,
- SourceLocation TemplateLoc,
- const TemplateArgumentListInfo &TemplateArgs);
-
- virtual TypeResult
- ActOnTemplateIdType(TemplateTy Template, SourceLocation TemplateLoc,
- SourceLocation LAngleLoc,
- ASTTemplateArgsPtr TemplateArgs,
- SourceLocation RAngleLoc);
-
- virtual TypeResult ActOnTagTemplateIdType(TypeResult Type,
- TagUseKind TUK,
- DeclSpec::TST TagSpec,
- SourceLocation TagLoc);
-
- OwningExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS,
- LookupResult &R,
- bool RequiresADL,
- const TemplateArgumentListInfo &TemplateArgs);
- OwningExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS,
- const DeclarationNameInfo &NameInfo,
- const TemplateArgumentListInfo &TemplateArgs);
-
- virtual TemplateNameKind ActOnDependentTemplateName(Scope *S,
- SourceLocation TemplateKWLoc,
- CXXScopeSpec &SS,
- UnqualifiedId &Name,
- TypeTy *ObjectType,
- bool EnteringContext,
- TemplateTy &Template);
-
- bool CheckClassTemplatePartialSpecializationArgs(
- TemplateParameterList *TemplateParams,
- const TemplateArgumentListBuilder &TemplateArgs,
- bool &MirrorsPrimaryTemplate);
-
- virtual DeclResult
- ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK,
- SourceLocation KWLoc,
- CXXScopeSpec &SS,
- TemplateTy Template,
- SourceLocation TemplateNameLoc,
- SourceLocation LAngleLoc,
- ASTTemplateArgsPtr TemplateArgs,
- SourceLocation RAngleLoc,
- AttributeList *Attr,
- MultiTemplateParamsArg TemplateParameterLists);
-
- virtual DeclPtrTy ActOnTemplateDeclarator(Scope *S,
- MultiTemplateParamsArg TemplateParameterLists,
- Declarator &D);
-
- virtual DeclPtrTy ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope,
- MultiTemplateParamsArg TemplateParameterLists,
- Declarator &D);
-
- bool
- CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
- TemplateSpecializationKind NewTSK,
- NamedDecl *PrevDecl,
- TemplateSpecializationKind PrevTSK,
- SourceLocation PrevPtOfInstantiation,
- bool &SuppressNew);
-
- bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD,
- const TemplateArgumentListInfo &ExplicitTemplateArgs,
- LookupResult &Previous);
-
- bool CheckFunctionTemplateSpecialization(FunctionDecl *FD,
- const TemplateArgumentListInfo *ExplicitTemplateArgs,
- LookupResult &Previous);
- bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous);
-
- virtual DeclResult
- ActOnExplicitInstantiation(Scope *S,
- SourceLocation ExternLoc,
- SourceLocation TemplateLoc,
- unsigned TagSpec,
- SourceLocation KWLoc,
- const CXXScopeSpec &SS,
- TemplateTy Template,
- SourceLocation TemplateNameLoc,
- SourceLocation LAngleLoc,
- ASTTemplateArgsPtr TemplateArgs,
- SourceLocation RAngleLoc,
- AttributeList *Attr);
-
- virtual DeclResult
- ActOnExplicitInstantiation(Scope *S,
- SourceLocation ExternLoc,
- SourceLocation TemplateLoc,
- unsigned TagSpec,
- SourceLocation KWLoc,
- CXXScopeSpec &SS,
- IdentifierInfo *Name,
- SourceLocation NameLoc,
- AttributeList *Attr);
-
- virtual DeclResult ActOnExplicitInstantiation(Scope *S,
- SourceLocation ExternLoc,
- SourceLocation TemplateLoc,
- Declarator &D);
-
- TemplateArgumentLoc
- SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template,
- SourceLocation TemplateLoc,
- SourceLocation RAngleLoc,
- Decl *Param,
- TemplateArgumentListBuilder &Converted);
-
- /// \brief Specifies the context in which a particular template
- /// argument is being checked.
- enum CheckTemplateArgumentKind {
- /// \brief The template argument was specified in the code or was
- /// instantiated with some deduced template arguments.
- CTAK_Specified,
-
- /// \brief The template argument was deduced via template argument
- /// deduction.
- CTAK_Deduced,
-
- /// \brief The template argument was deduced from an array bound
- /// via template argument deduction.
- CTAK_DeducedFromArrayBound
- };
-
- bool CheckTemplateArgument(NamedDecl *Param,
- const TemplateArgumentLoc &Arg,
- TemplateDecl *Template,
- SourceLocation TemplateLoc,
- SourceLocation RAngleLoc,
- TemplateArgumentListBuilder &Converted,
- CheckTemplateArgumentKind CTAK = CTAK_Specified);
-
- bool CheckTemplateArgumentList(TemplateDecl *Template,
- SourceLocation TemplateLoc,
- const TemplateArgumentListInfo &TemplateArgs,
- bool PartialTemplateArgs,
- TemplateArgumentListBuilder &Converted);
-
- bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
- const TemplateArgumentLoc &Arg,
- TemplateArgumentListBuilder &Converted);
-
- bool CheckTemplateArgument(TemplateTypeParmDecl *Param,
- TypeSourceInfo *Arg);
- bool CheckTemplateArgumentPointerToMember(Expr *Arg,
- TemplateArgument &Converted);
- bool CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
- QualType InstantiatedParamType, Expr *&Arg,
- TemplateArgument &Converted,
- CheckTemplateArgumentKind CTAK = CTAK_Specified);
- bool CheckTemplateArgument(TemplateTemplateParmDecl *Param,
- const TemplateArgumentLoc &Arg);
-
- OwningExprResult
- BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg,
- QualType ParamType,
- SourceLocation Loc);
- OwningExprResult
- BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
- SourceLocation Loc);
-
- /// \brief Enumeration describing how template parameter lists are compared
- /// for equality.
- enum TemplateParameterListEqualKind {
- /// \brief We are matching the template parameter lists of two templates
- /// that might be redeclarations.
- ///
- /// \code
- /// template<typename T> struct X;
- /// template<typename T> struct X;
- /// \endcode
- TPL_TemplateMatch,
-
- /// \brief We are matching the template parameter lists of two template
- /// template parameters as part of matching the template parameter lists
- /// of two templates that might be redeclarations.
- ///
- /// \code
- /// template<template<int I> class TT> struct X;
- /// template<template<int Value> class Other> struct X;
- /// \endcode
- TPL_TemplateTemplateParmMatch,
-
- /// \brief We are matching the template parameter lists of a template
- /// template argument against the template parameter lists of a template
- /// template parameter.
- ///
- /// \code
- /// template<template<int Value> class Metafun> struct X;
- /// template<int Value> struct integer_c;
- /// X<integer_c> xic;
- /// \endcode
- TPL_TemplateTemplateArgumentMatch
- };
-
- bool TemplateParameterListsAreEqual(TemplateParameterList *New,
- TemplateParameterList *Old,
- bool Complain,
- TemplateParameterListEqualKind Kind,
- SourceLocation TemplateArgLoc
- = SourceLocation());
-
- bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
-
- /// \brief Called when the parser has parsed a C++ typename
- /// specifier, e.g., "typename T::type".
- ///
- /// \param S The scope in which this typename type occurs.
- /// \param TypenameLoc the location of the 'typename' keyword
- /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
- /// \param II the identifier we're retrieving (e.g., 'type' in the example).
- /// \param IdLoc the location of the identifier.
- virtual TypeResult
- ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
- const CXXScopeSpec &SS, const IdentifierInfo &II,
- SourceLocation IdLoc);
-
- /// \brief Called when the parser has parsed a C++ typename
- /// specifier that ends in a template-id, e.g.,
- /// "typename MetaFun::template apply<T1, T2>".
- ///
- /// \param S The scope in which this typename type occurs.
- /// \param TypenameLoc the location of the 'typename' keyword
- /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
- /// \param TemplateLoc the location of the 'template' keyword, if any.
- /// \param Ty the type that the typename specifier refers to.
- virtual TypeResult
- ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
- const CXXScopeSpec &SS, SourceLocation TemplateLoc,
- TypeTy *Ty);
-
- QualType CheckTypenameType(ElaboratedTypeKeyword Keyword,
- NestedNameSpecifier *NNS,
- const IdentifierInfo &II,
- SourceLocation KeywordLoc,
- SourceRange NNSRange,
- SourceLocation IILoc);
-
- TypeSourceInfo *RebuildTypeInCurrentInstantiation(TypeSourceInfo *T,
- SourceLocation Loc,
- DeclarationName Name);
- bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS);
-
- std::string
- getTemplateArgumentBindingsText(const TemplateParameterList *Params,
- const TemplateArgumentList &Args);
-
- std::string
- getTemplateArgumentBindingsText(const TemplateParameterList *Params,
- const TemplateArgument *Args,
- unsigned NumArgs);
-
- /// \brief Describes the result of template argument deduction.
- ///
- /// The TemplateDeductionResult enumeration describes the result of
- /// template argument deduction, as returned from
- /// DeduceTemplateArguments(). The separate TemplateDeductionInfo
- /// structure provides additional information about the results of
- /// template argument deduction, e.g., the deduced template argument
- /// list (if successful) or the specific template parameters or
- /// deduced arguments that were involved in the failure.
- enum TemplateDeductionResult {
- /// \brief Template argument deduction was successful.
- TDK_Success = 0,
- /// \brief Template argument deduction exceeded the maximum template
- /// instantiation depth (which has already been diagnosed).
- TDK_InstantiationDepth,
- /// \brief Template argument deduction did not deduce a value
- /// for every template parameter.
- TDK_Incomplete,
- /// \brief Template argument deduction produced inconsistent
- /// deduced values for the given template parameter.
- TDK_Inconsistent,
- /// \brief Template argument deduction failed due to inconsistent
- /// cv-qualifiers on a template parameter type that would
- /// otherwise be deduced, e.g., we tried to deduce T in "const T"
- /// but were given a non-const "X".
- TDK_Underqualified,
- /// \brief Substitution of the deduced template argument values
- /// resulted in an error.
- TDK_SubstitutionFailure,
- /// \brief Substitution of the deduced template argument values
- /// into a non-deduced context produced a type or value that
- /// produces a type that does not match the original template
- /// arguments provided.
- TDK_NonDeducedMismatch,
- /// \brief When performing template argument deduction for a function
- /// template, there were too many call arguments.
- TDK_TooManyArguments,
- /// \brief When performing template argument deduction for a function
- /// template, there were too few call arguments.
- TDK_TooFewArguments,
- /// \brief The explicitly-specified template arguments were not valid
- /// template arguments for the given template.
- TDK_InvalidExplicitArguments,
- /// \brief The arguments included an overloaded function name that could
- /// not be resolved to a suitable function.
- TDK_FailedOverloadResolution
- };
-
- /// \brief Provides information about an attempted template argument
- /// deduction, whose success or failure was described by a
- /// TemplateDeductionResult value.
- class TemplateDeductionInfo {
- /// \brief The context in which the template arguments are stored.
- ASTContext &Context;
-
- /// \brief The deduced template argument list.
- ///
- TemplateArgumentList *Deduced;
-
- /// \brief The source location at which template argument
- /// deduction is occurring.
- SourceLocation Loc;
-
- // do not implement these
- TemplateDeductionInfo(const TemplateDeductionInfo&);
- TemplateDeductionInfo &operator=(const TemplateDeductionInfo&);
-
- public:
- TemplateDeductionInfo(ASTContext &Context, SourceLocation Loc)
- : Context(Context), Deduced(0), Loc(Loc) { }
-
- ~TemplateDeductionInfo() {
- // FIXME: if (Deduced) Deduced->Destroy(Context);
- }
-
- /// \brief Returns the location at which template argument is
- /// occuring.
- SourceLocation getLocation() const {
- return Loc;
- }
-
- /// \brief Take ownership of the deduced template argument list.
- TemplateArgumentList *take() {
- TemplateArgumentList *Result = Deduced;
- Deduced = 0;
- return Result;
- }
-
- /// \brief Provide a new template argument list that contains the
- /// results of template argument deduction.
- void reset(TemplateArgumentList *NewDeduced) {
- // FIXME: if (Deduced) Deduced->Destroy(Context);
- Deduced = NewDeduced;
- }
-
- /// \brief The template parameter to which a template argument
- /// deduction failure refers.
- ///
- /// Depending on the result of template argument deduction, this
- /// template parameter may have different meanings:
- ///
- /// TDK_Incomplete: this is the first template parameter whose
- /// corresponding template argument was not deduced.
- ///
- /// TDK_Inconsistent: this is the template parameter for which
- /// two different template argument values were deduced.
- TemplateParameter Param;
-
- /// \brief The first template argument to which the template
- /// argument deduction failure refers.
- ///
- /// Depending on the result of the template argument deduction,
- /// this template argument may have different meanings:
- ///
- /// TDK_Inconsistent: this argument is the first value deduced
- /// for the corresponding template parameter.
- ///
- /// TDK_SubstitutionFailure: this argument is the template
- /// argument we were instantiating when we encountered an error.
- ///
- /// TDK_NonDeducedMismatch: this is the template argument
- /// provided in the source code.
- TemplateArgument FirstArg;
-
- /// \brief The second template argument to which the template
- /// argument deduction failure refers.
- ///
- /// FIXME: Finish documenting this.
- TemplateArgument SecondArg;
- };
-
- TemplateDeductionResult
- DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
- const TemplateArgumentList &TemplateArgs,
- TemplateDeductionInfo &Info);
-
- TemplateDeductionResult
- SubstituteExplicitTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
- const TemplateArgumentListInfo &ExplicitTemplateArgs,
- llvm::SmallVectorImpl<DeducedTemplateArgument> &Deduced,
- llvm::SmallVectorImpl<QualType> &ParamTypes,
- QualType *FunctionType,
- TemplateDeductionInfo &Info);
-
- TemplateDeductionResult
- FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
- llvm::SmallVectorImpl<DeducedTemplateArgument> &Deduced,
- unsigned NumExplicitlySpecified,
- FunctionDecl *&Specialization,
- TemplateDeductionInfo &Info);
-
- TemplateDeductionResult
- DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
- const TemplateArgumentListInfo *ExplicitTemplateArgs,
- Expr **Args, unsigned NumArgs,
- FunctionDecl *&Specialization,
- TemplateDeductionInfo &Info);
-
- TemplateDeductionResult
- DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
- const TemplateArgumentListInfo *ExplicitTemplateArgs,
- QualType ArgFunctionType,
- FunctionDecl *&Specialization,
- TemplateDeductionInfo &Info);
-
- TemplateDeductionResult
- DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
- QualType ToType,
- CXXConversionDecl *&Specialization,
- TemplateDeductionInfo &Info);
-
- TemplateDeductionResult
- DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
- const TemplateArgumentListInfo *ExplicitTemplateArgs,
- FunctionDecl *&Specialization,
- TemplateDeductionInfo &Info);
-
- FunctionTemplateDecl *getMoreSpecializedTemplate(FunctionTemplateDecl *FT1,
- FunctionTemplateDecl *FT2,
- SourceLocation Loc,
- TemplatePartialOrderingContext TPOC);
- UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin,
- UnresolvedSetIterator SEnd,
- TemplatePartialOrderingContext TPOC,
- SourceLocation Loc,
- const PartialDiagnostic &NoneDiag,
- const PartialDiagnostic &AmbigDiag,
- const PartialDiagnostic &CandidateDiag);
-
- ClassTemplatePartialSpecializationDecl *
- getMoreSpecializedPartialSpecialization(
- ClassTemplatePartialSpecializationDecl *PS1,
- ClassTemplatePartialSpecializationDecl *PS2,
- SourceLocation Loc);
-
- void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
- bool OnlyDeduced,
- unsigned Depth,
- llvm::SmallVectorImpl<bool> &Used);
- void MarkDeducedTemplateParameters(FunctionTemplateDecl *FunctionTemplate,
- llvm::SmallVectorImpl<bool> &Deduced);
-
- //===--------------------------------------------------------------------===//
- // C++ Template Instantiation
- //
-
- MultiLevelTemplateArgumentList getTemplateInstantiationArgs(NamedDecl *D,
- const TemplateArgumentList *Innermost = 0,
- bool RelativeToPrimary = false,
- const FunctionDecl *Pattern = 0);
-
- /// \brief A template instantiation that is currently in progress.
- struct ActiveTemplateInstantiation {
- /// \brief The kind of template instantiation we are performing
- enum InstantiationKind {
- /// We are instantiating a template declaration. The entity is
- /// the declaration we're instantiating (e.g., a CXXRecordDecl).
- TemplateInstantiation,
-
- /// We are instantiating a default argument for a template
- /// parameter. The Entity is the template, and
- /// TemplateArgs/NumTemplateArguments provides the template
- /// arguments as specified.
- /// FIXME: Use a TemplateArgumentList
- DefaultTemplateArgumentInstantiation,
-
- /// We are instantiating a default argument for a function.
- /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
- /// provides the template arguments as specified.
- DefaultFunctionArgumentInstantiation,
-
- /// We are substituting explicit template arguments provided for
- /// a function template. The entity is a FunctionTemplateDecl.
- ExplicitTemplateArgumentSubstitution,
-
- /// We are substituting template argument determined as part of
- /// template argument deduction for either a class template
- /// partial specialization or a function template. The
- /// Entity is either a ClassTemplatePartialSpecializationDecl or
- /// a FunctionTemplateDecl.
- DeducedTemplateArgumentSubstitution,
-
- /// We are substituting prior template arguments into a new
- /// template parameter. The template parameter itself is either a
- /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
- PriorTemplateArgumentSubstitution,
-
- /// We are checking the validity of a default template argument that
- /// has been used when naming a template-id.
- DefaultTemplateArgumentChecking
- } Kind;
-
- /// \brief The point of instantiation within the source code.
- SourceLocation PointOfInstantiation;
-
- /// \brief The template in which we are performing the instantiation,
- /// for substitutions of prior template arguments.
- TemplateDecl *Template;
-
- /// \brief The entity that is being instantiated.
- uintptr_t Entity;
-
- /// \brief The list of template arguments we are substituting, if they
- /// are not part of the entity.
- const TemplateArgument *TemplateArgs;
-
- /// \brief The number of template arguments in TemplateArgs.
- unsigned NumTemplateArgs;
-
- /// \brief The source range that covers the construct that cause
- /// the instantiation, e.g., the template-id that causes a class
- /// template instantiation.
- SourceRange InstantiationRange;
-
- ActiveTemplateInstantiation()
- : Kind(TemplateInstantiation), Template(0), Entity(0), TemplateArgs(0),
- NumTemplateArgs(0) {}
-
- /// \brief Determines whether this template is an actual instantiation
- /// that should be counted toward the maximum instantiation depth.
- bool isInstantiationRecord() const;
-
- friend bool operator==(const ActiveTemplateInstantiation &X,
- const ActiveTemplateInstantiation &Y) {
- if (X.Kind != Y.Kind)
- return false;
-
- if (X.Entity != Y.Entity)
- return false;
-
- switch (X.Kind) {
- case TemplateInstantiation:
- return true;
-
- case PriorTemplateArgumentSubstitution:
- case DefaultTemplateArgumentChecking:
- if (X.Template != Y.Template)
- return false;
-
- // Fall through
-
- case DefaultTemplateArgumentInstantiation:
- case ExplicitTemplateArgumentSubstitution:
- case DeducedTemplateArgumentSubstitution:
- case DefaultFunctionArgumentInstantiation:
- return X.TemplateArgs == Y.TemplateArgs;
-
- }
-
- return true;
- }
-
- friend bool operator!=(const ActiveTemplateInstantiation &X,
- const ActiveTemplateInstantiation &Y) {
- return !(X == Y);
- }
- };
-
- /// \brief List of active template instantiations.
- ///
- /// This vector is treated as a stack. As one template instantiation
- /// requires another template instantiation, additional
- /// instantiations are pushed onto the stack up to a
- /// user-configurable limit LangOptions::InstantiationDepth.
- llvm::SmallVector<ActiveTemplateInstantiation, 16>
- ActiveTemplateInstantiations;
-
- /// \brief The number of ActiveTemplateInstantiation entries in
- /// \c ActiveTemplateInstantiations that are not actual instantiations and,
- /// therefore, should not be counted as part of the instantiation depth.
- unsigned NonInstantiationEntries;
-
- /// \brief The last template from which a template instantiation
- /// error or warning was produced.
- ///
- /// This value is used to suppress printing of redundant template
- /// instantiation backtraces when there are multiple errors in the
- /// same instantiation. FIXME: Does this belong in Sema? It's tough
- /// to implement it anywhere else.
- ActiveTemplateInstantiation LastTemplateInstantiationErrorContext;
-
- /// \brief The stack of calls expression undergoing template instantiation.
- ///
- /// The top of this stack is used by a fixit instantiating unresolved
- /// function calls to fix the AST to match the textual change it prints.
- llvm::SmallVector<CallExpr *, 8> CallsUndergoingInstantiation;
-
- /// \brief A stack object to be created when performing template
- /// instantiation.
- ///
- /// Construction of an object of type \c InstantiatingTemplate
- /// pushes the current instantiation onto the stack of active
- /// instantiations. If the size of this stack exceeds the maximum
- /// number of recursive template instantiations, construction
- /// produces an error and evaluates true.
- ///
- /// Destruction of this object will pop the named instantiation off
- /// the stack.
- struct InstantiatingTemplate {
- /// \brief Note that we are instantiating a class template,
- /// function template, or a member thereof.
- InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
- Decl *Entity,
- SourceRange InstantiationRange = SourceRange());
-
- /// \brief Note that we are instantiating a default argument in a
- /// template-id.
- InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
- TemplateDecl *Template,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs,
- SourceRange InstantiationRange = SourceRange());
-
- /// \brief Note that we are instantiating a default argument in a
- /// template-id.
- InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
- FunctionTemplateDecl *FunctionTemplate,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs,
- ActiveTemplateInstantiation::InstantiationKind Kind,
- SourceRange InstantiationRange = SourceRange());
-
- /// \brief Note that we are instantiating as part of template
- /// argument deduction for a class template partial
- /// specialization.
- InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
- ClassTemplatePartialSpecializationDecl *PartialSpec,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs,
- SourceRange InstantiationRange = SourceRange());
-
- InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
- ParmVarDecl *Param,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs,
- SourceRange InstantiationRange = SourceRange());
-
- /// \brief Note that we are substituting prior template arguments into a
- /// non-type or template template parameter.
- InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
- TemplateDecl *Template,
- NonTypeTemplateParmDecl *Param,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs,
- SourceRange InstantiationRange);
-
- InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
- TemplateDecl *Template,
- TemplateTemplateParmDecl *Param,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs,
- SourceRange InstantiationRange);
-
- /// \brief Note that we are checking the default template argument
- /// against the template parameter for a given template-id.
- InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
- TemplateDecl *Template,
- NamedDecl *Param,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs,
- SourceRange InstantiationRange);
-
-
- /// \brief Note that we have finished instantiating this template.
- void Clear();
-
- ~InstantiatingTemplate() { Clear(); }
-
- /// \brief Determines whether we have exceeded the maximum
- /// recursive template instantiations.
- operator bool() const { return Invalid; }
-
- private:
- Sema &SemaRef;
- bool Invalid;
-
- bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
- SourceRange InstantiationRange);
-
- InstantiatingTemplate(const InstantiatingTemplate&); // not implemented
-
- InstantiatingTemplate&
- operator=(const InstantiatingTemplate&); // not implemented
- };
-
- void PrintInstantiationStack();
-
- /// \brief Determines whether we are currently in a context where
- /// template argument substitution failures are not considered
- /// errors.
- ///
- /// When this routine returns true, the emission of most diagnostics
- /// will be suppressed and there will be no local error recovery.
- bool isSFINAEContext() const;
-
- /// \brief RAII class used to determine whether SFINAE has
- /// trapped any errors that occur during template argument
- /// deduction.
- class SFINAETrap {
- Sema &SemaRef;
- unsigned PrevSFINAEErrors;
- public:
- explicit SFINAETrap(Sema &SemaRef)
- : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors) { }
-
- ~SFINAETrap() { SemaRef.NumSFINAEErrors = PrevSFINAEErrors; }
-
- /// \brief Determine whether any SFINAE errors have been trapped.
- bool hasErrorOccurred() const {
- return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
- }
- };
-
- /// \brief RAII class that determines when any errors have occurred
- /// between the time the instance was created and the time it was
- /// queried.
- class ErrorTrap {
- Sema &SemaRef;
- unsigned PrevErrors;
-
- public:
- explicit ErrorTrap(Sema &SemaRef)
- : SemaRef(SemaRef), PrevErrors(SemaRef.getDiagnostics().getNumErrors()) {}
-
- /// \brief Determine whether any errors have occurred since this
- /// object instance was created.
- bool hasErrorOccurred() const {
- return SemaRef.getDiagnostics().getNumErrors() > PrevErrors;
- }
- };
-
- /// \brief A stack-allocated class that identifies which local
- /// variable declaration instantiations are present in this scope.
- ///
- /// A new instance of this class type will be created whenever we
- /// instantiate a new function declaration, which will have its own
- /// set of parameter declarations.
- class LocalInstantiationScope {
- /// \brief Reference to the semantic analysis that is performing
- /// this template instantiation.
- Sema &SemaRef;
-
- /// \brief A mapping from local declarations that occur
- /// within a template to their instantiations.
- ///
- /// This mapping is used during instantiation to keep track of,
- /// e.g., function parameter and variable declarations. For example,
- /// given:
- ///
- /// \code
- /// template<typename T> T add(T x, T y) { return x + y; }
- /// \endcode
- ///
- /// when we instantiate add<int>, we will introduce a mapping from
- /// the ParmVarDecl for 'x' that occurs in the template to the
- /// instantiated ParmVarDecl for 'x'.
- llvm::DenseMap<const Decl *, Decl *> LocalDecls;
-
- /// \brief The outer scope, which contains local variable
- /// definitions from some other instantiation (that may not be
- /// relevant to this particular scope).
- LocalInstantiationScope *Outer;
-
- /// \brief Whether we have already exited this scope.
- bool Exited;
-
- /// \brief Whether to combine this scope with the outer scope, such that
- /// lookup will search our outer scope.
- bool CombineWithOuterScope;
-
- // This class is non-copyable
- LocalInstantiationScope(const LocalInstantiationScope &);
- LocalInstantiationScope &operator=(const LocalInstantiationScope &);
-
- public:
- LocalInstantiationScope(Sema &SemaRef, bool CombineWithOuterScope = false)
- : SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope),
- Exited(false), CombineWithOuterScope(CombineWithOuterScope)
- {
- SemaRef.CurrentInstantiationScope = this;
- }
-
- ~LocalInstantiationScope() {
- Exit();
- }
-
- /// \brief Exit this local instantiation scope early.
- void Exit() {
- if (Exited)
- return;
-
- SemaRef.CurrentInstantiationScope = Outer;
- Exited = true;
- }
-
- Decl *getInstantiationOf(const Decl *D);
-
- VarDecl *getInstantiationOf(const VarDecl *Var) {
- return cast<VarDecl>(getInstantiationOf(cast<Decl>(Var)));
- }
-
- ParmVarDecl *getInstantiationOf(const ParmVarDecl *Var) {
- return cast<ParmVarDecl>(getInstantiationOf(cast<Decl>(Var)));
- }
-
- NonTypeTemplateParmDecl *getInstantiationOf(
- const NonTypeTemplateParmDecl *Var) {
- return cast<NonTypeTemplateParmDecl>(getInstantiationOf(cast<Decl>(Var)));
- }
-
- void InstantiatedLocal(const Decl *D, Decl *Inst);
- };
-
- /// \brief The current instantiation scope used to store local
- /// variables.
- LocalInstantiationScope *CurrentInstantiationScope;
-
- /// \brief The number of typos corrected by CorrectTypo.
- unsigned TyposCorrected;
-
- /// \brief Worker object for performing CFG-based warnings.
- sema::AnalysisBasedWarnings AnalysisWarnings;
-
- /// \brief An entity for which implicit template instantiation is required.
- ///
- /// The source location associated with the declaration is the first place in
- /// the source code where the declaration was "used". It is not necessarily
- /// the point of instantiation (which will be either before or after the
- /// namespace-scope declaration that triggered this implicit instantiation),
- /// However, it is the location that diagnostics should generally refer to,
- /// because users will need to know what code triggered the instantiation.
- typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
-
- /// \brief The queue of implicit template instantiations that are required
- /// but have not yet been performed.
- std::deque<PendingImplicitInstantiation> PendingImplicitInstantiations;
-
- /// \brief The queue of implicit template instantiations that are required
- /// and must be performed within the current local scope.
- ///
- /// This queue is only used for member functions of local classes in
- /// templates, which must be instantiated in the same scope as their
- /// enclosing function, so that they can reference function-local
- /// types, static variables, enumerators, etc.
- std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
-
- void PerformPendingImplicitInstantiations(bool LocalOnly = false);
-
- TypeSourceInfo *SubstType(TypeSourceInfo *T,
- const MultiLevelTemplateArgumentList &TemplateArgs,
- SourceLocation Loc, DeclarationName Entity);
-
- QualType SubstType(QualType T,
- const MultiLevelTemplateArgumentList &TemplateArgs,
- SourceLocation Loc, DeclarationName Entity);
-
- TypeSourceInfo *SubstFunctionDeclType(TypeSourceInfo *T,
- const MultiLevelTemplateArgumentList &TemplateArgs,
- SourceLocation Loc,
- DeclarationName Entity);
- ParmVarDecl *SubstParmVarDecl(ParmVarDecl *D,
- const MultiLevelTemplateArgumentList &TemplateArgs);
- OwningExprResult SubstExpr(Expr *E,
- const MultiLevelTemplateArgumentList &TemplateArgs);
-
- OwningStmtResult SubstStmt(Stmt *S,
- const MultiLevelTemplateArgumentList &TemplateArgs);
-
- Decl *SubstDecl(Decl *D, DeclContext *Owner,
- const MultiLevelTemplateArgumentList &TemplateArgs);
-
- bool
- SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
- CXXRecordDecl *Pattern,
- const MultiLevelTemplateArgumentList &TemplateArgs);
-
- bool
- InstantiateClass(SourceLocation PointOfInstantiation,
- CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
- const MultiLevelTemplateArgumentList &TemplateArgs,
- TemplateSpecializationKind TSK,
- bool Complain = true);
-
- void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
- Decl *Pattern, Decl *Inst);
-
- bool
- InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation,
- ClassTemplateSpecializationDecl *ClassTemplateSpec,
- TemplateSpecializationKind TSK,
- bool Complain = true);
-
- void InstantiateClassMembers(SourceLocation PointOfInstantiation,
- CXXRecordDecl *Instantiation,
- const MultiLevelTemplateArgumentList &TemplateArgs,
- TemplateSpecializationKind TSK);
-
- void InstantiateClassTemplateSpecializationMembers(
- SourceLocation PointOfInstantiation,
- ClassTemplateSpecializationDecl *ClassTemplateSpec,
- TemplateSpecializationKind TSK);
-
- NestedNameSpecifier *
- SubstNestedNameSpecifier(NestedNameSpecifier *NNS,
- SourceRange Range,
- const MultiLevelTemplateArgumentList &TemplateArgs);
- DeclarationNameInfo
- SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo,
- const MultiLevelTemplateArgumentList &TemplateArgs);
- TemplateName
- SubstTemplateName(TemplateName Name, SourceLocation Loc,
- const MultiLevelTemplateArgumentList &TemplateArgs);
- bool Subst(const TemplateArgumentLoc &Arg, TemplateArgumentLoc &Result,
- const MultiLevelTemplateArgumentList &TemplateArgs);
-
- void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
- FunctionDecl *Function,
- bool Recursive = false,
- bool DefinitionRequired = false);
- void InstantiateStaticDataMemberDefinition(
- SourceLocation PointOfInstantiation,
- VarDecl *Var,
- bool Recursive = false,
- bool DefinitionRequired = false);
-
- void InstantiateMemInitializers(CXXConstructorDecl *New,
- const CXXConstructorDecl *Tmpl,
- const MultiLevelTemplateArgumentList &TemplateArgs);
-
- NamedDecl *FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
- const MultiLevelTemplateArgumentList &TemplateArgs);
- DeclContext *FindInstantiatedContext(SourceLocation Loc, DeclContext *DC,
- const MultiLevelTemplateArgumentList &TemplateArgs);
-
- // Objective-C declarations.
- virtual DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
- IdentifierInfo *ClassName,
- SourceLocation ClassLoc,
- IdentifierInfo *SuperName,
- SourceLocation SuperLoc,
- const DeclPtrTy *ProtoRefs,
- unsigned NumProtoRefs,
- const SourceLocation *ProtoLocs,
- SourceLocation EndProtoLoc,
- AttributeList *AttrList);
-
- virtual DeclPtrTy ActOnCompatiblityAlias(
- SourceLocation AtCompatibilityAliasLoc,
- IdentifierInfo *AliasName, SourceLocation AliasLocation,
- IdentifierInfo *ClassName, SourceLocation ClassLocation);
-
- void CheckForwardProtocolDeclarationForCircularDependency(
- IdentifierInfo *PName,
- SourceLocation &PLoc, SourceLocation PrevLoc,
- const ObjCList<ObjCProtocolDecl> &PList);
-
- virtual DeclPtrTy ActOnStartProtocolInterface(
- SourceLocation AtProtoInterfaceLoc,
- IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc,
- const DeclPtrTy *ProtoRefNames, unsigned NumProtoRefs,
- const SourceLocation *ProtoLocs,
- SourceLocation EndProtoLoc,
- AttributeList *AttrList);
-
- virtual DeclPtrTy ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
- IdentifierInfo *ClassName,
- SourceLocation ClassLoc,
- IdentifierInfo *CategoryName,
- SourceLocation CategoryLoc,
- const DeclPtrTy *ProtoRefs,
- unsigned NumProtoRefs,
- const SourceLocation *ProtoLocs,
- SourceLocation EndProtoLoc);
-
- virtual DeclPtrTy ActOnStartClassImplementation(
- SourceLocation AtClassImplLoc,
- IdentifierInfo *ClassName, SourceLocation ClassLoc,
- IdentifierInfo *SuperClassname,
- SourceLocation SuperClassLoc);
-
- virtual DeclPtrTy ActOnStartCategoryImplementation(
- SourceLocation AtCatImplLoc,
- IdentifierInfo *ClassName,
- SourceLocation ClassLoc,
- IdentifierInfo *CatName,
- SourceLocation CatLoc);
-
- virtual DeclPtrTy ActOnForwardClassDeclaration(SourceLocation Loc,
- IdentifierInfo **IdentList,
- SourceLocation *IdentLocs,
- unsigned NumElts);
-
- virtual DeclPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc,
- const IdentifierLocPair *IdentList,
- unsigned NumElts,
- AttributeList *attrList);
-
- virtual void FindProtocolDeclaration(bool WarnOnDeclarations,
- const IdentifierLocPair *ProtocolId,
- unsigned NumProtocols,
- llvm::SmallVectorImpl<DeclPtrTy> &Protocols);
-
- /// Ensure attributes are consistent with type.
- /// \param [in, out] Attributes The attributes to check; they will
- /// be modified to be consistent with \arg PropertyTy.
- void CheckObjCPropertyAttributes(DeclPtrTy PropertyPtrTy,
- SourceLocation Loc,
- unsigned &Attributes);
- void ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCContainerDecl *DC);
- void DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
- ObjCPropertyDecl *SuperProperty,
- const IdentifierInfo *Name);
- void ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl);
-
- void CompareMethodParamsInBaseAndSuper(Decl *IDecl,
- ObjCMethodDecl *MethodDecl,
- bool IsInstance);
-
- void CompareProperties(Decl *CDecl, DeclPtrTy MergeProtocols);
-
- void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
- ObjCInterfaceDecl *ID);
-
- void MatchOneProtocolPropertiesInClass(Decl *CDecl,
- ObjCProtocolDecl *PDecl);
-
- virtual void ActOnAtEnd(Scope *S, SourceRange AtEnd,
- DeclPtrTy classDecl,
- DeclPtrTy *allMethods = 0, unsigned allNum = 0,
- DeclPtrTy *allProperties = 0, unsigned pNum = 0,
- DeclGroupPtrTy *allTUVars = 0, unsigned tuvNum = 0);
-
- virtual DeclPtrTy ActOnProperty(Scope *S, SourceLocation AtLoc,
- FieldDeclarator &FD, ObjCDeclSpec &ODS,
- Selector GetterSel, Selector SetterSel,
- DeclPtrTy ClassCategory,
- bool *OverridingProperty,
- tok::ObjCKeywordKind MethodImplKind);
-
- virtual DeclPtrTy ActOnPropertyImplDecl(Scope *S,
- SourceLocation AtLoc,
- SourceLocation PropertyLoc,
- bool ImplKind,DeclPtrTy ClassImplDecl,
- IdentifierInfo *PropertyId,
- IdentifierInfo *PropertyIvar);
-
- virtual DeclPtrTy ActOnMethodDeclaration(
- SourceLocation BeginLoc, // location of the + or -.
- SourceLocation EndLoc, // location of the ; or {.
- tok::TokenKind MethodType,
- DeclPtrTy ClassDecl, ObjCDeclSpec &ReturnQT, TypeTy *ReturnType,
- Selector Sel,
- // optional arguments. The number of types/arguments is obtained
- // from the Sel.getNumArgs().
- ObjCArgInfo *ArgInfo,
- DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, // c-style args
- AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind,
- bool isVariadic = false);
-
- // Helper method for ActOnClassMethod/ActOnInstanceMethod.
- // Will search "local" class/category implementations for a method decl.
- // Will also search in class's root looking for instance method.
- // Returns 0 if no method is found.
- ObjCMethodDecl *LookupPrivateClassMethod(Selector Sel,
- ObjCInterfaceDecl *CDecl);
- ObjCMethodDecl *LookupPrivateInstanceMethod(Selector Sel,
- ObjCInterfaceDecl *ClassDecl);
-
- OwningExprResult
- HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT,
- Expr *BaseExpr,
- DeclarationName MemberName,
- SourceLocation MemberLoc);
-
- virtual OwningExprResult
- ActOnClassPropertyRefExpr(IdentifierInfo &receiverName,
- IdentifierInfo &propertyName,
- SourceLocation receiverNameLoc,
- SourceLocation propertyNameLoc);
-
- virtual ObjCMessageKind getObjCMessageKind(Scope *S,
- IdentifierInfo *Name,
- SourceLocation NameLoc,
- bool IsSuper,
- bool HasTrailingDot,
- TypeTy *&ReceiverType);
-
- virtual OwningExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc,
- Selector Sel,
- SourceLocation LBracLoc,
- SourceLocation SelectorLoc,
- SourceLocation RBracLoc,
- MultiExprArg Args);
-
- OwningExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo,
- QualType ReceiverType,
- SourceLocation SuperLoc,
- Selector Sel,
- ObjCMethodDecl *Method,
- SourceLocation LBracLoc,
- SourceLocation RBracLoc,
- MultiExprArg Args);
-
- virtual OwningExprResult ActOnClassMessage(Scope *S,
- TypeTy *Receiver,
- Selector Sel,
- SourceLocation LBracLoc,
- SourceLocation SelectorLoc,
- SourceLocation RBracLoc,
- MultiExprArg Args);
-
- OwningExprResult BuildInstanceMessage(ExprArg Receiver,
- QualType ReceiverType,
- SourceLocation SuperLoc,
- Selector Sel,
- ObjCMethodDecl *Method,
- SourceLocation LBracLoc,
- SourceLocation RBracLoc,
- MultiExprArg Args);
-
- virtual OwningExprResult ActOnInstanceMessage(Scope *S,
- ExprArg Receiver,
- Selector Sel,
- SourceLocation LBracLoc,
- SourceLocation SelectorLoc,
- SourceLocation RBracLoc,
- MultiExprArg Args);
-
-
- /// ActOnPragmaOptionsAlign - Called on well formed #pragma options align.
- virtual void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
- SourceLocation PragmaLoc,
- SourceLocation KindLoc);
-
- /// ActOnPragmaPack - Called on well formed #pragma pack(...).
- virtual void ActOnPragmaPack(PragmaPackKind Kind,
- IdentifierInfo *Name,
- ExprTy *Alignment,
- SourceLocation PragmaLoc,
- SourceLocation LParenLoc,
- SourceLocation RParenLoc);
-
- /// ActOnPragmaUnused - Called on well-formed '#pragma unused'.
- virtual void ActOnPragmaUnused(const Token *Identifiers,
- unsigned NumIdentifiers, Scope *curScope,
- SourceLocation PragmaLoc,
- SourceLocation LParenLoc,
- SourceLocation RParenLoc);
-
- /// ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
- virtual void ActOnPragmaVisibility(bool IsPush, const IdentifierInfo* VisType,
- SourceLocation PragmaLoc);
-
- NamedDecl *DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II);
- void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W);
-
- /// ActOnPragmaWeakID - Called on well formed #pragma weak ident.
- virtual void ActOnPragmaWeakID(IdentifierInfo* WeakName,
- SourceLocation PragmaLoc,
- SourceLocation WeakNameLoc);
-
- /// ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
- virtual void ActOnPragmaWeakAlias(IdentifierInfo* WeakName,
- IdentifierInfo* AliasName,
- SourceLocation PragmaLoc,
- SourceLocation WeakNameLoc,
- SourceLocation AliasNameLoc);
-
- /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
- /// a the record decl, to handle '#pragma pack' and '#pragma options align'.
- void AddAlignmentAttributesForRecord(RecordDecl *RD);
-
- /// FreePackedContext - Deallocate and null out PackContext.
- void FreePackedContext();
-
- /// AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used,
- /// add an appropriate visibility attribute.
- void AddPushedVisibilityAttribute(Decl *RD);
-
- /// PushPragmaVisibility - Push the top element of the visibility stack; used
- /// for '#pragma GCC visibility' and visibility attributes on namespaces.
- void PushPragmaVisibility(VisibilityAttr::VisibilityTypes type);
-
- /// PopPragmaVisibility - Pop the top element of the visibility stack; used
- /// for '#pragma GCC visibility' and visibility attributes on namespaces.
- void PopPragmaVisibility();
-
- /// FreeVisContext - Deallocate and null out VisContext.
- void FreeVisContext();
-
- /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
- void AddAlignedAttr(SourceLocation AttrLoc, Decl *D, Expr *E);
-
- /// CastCategory - Get the correct forwarded implicit cast result category
- /// from the inner expression.
- ImplicitCastExpr::ResultCategory CastCategory(Expr *E);
-
- /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
- /// cast. If there is already an implicit cast, merge into the existing one.
- /// If isLvalue, the result of the cast is an lvalue.
- void ImpCastExprToType(Expr *&Expr, QualType Type, CastExpr::CastKind Kind,
- ImplicitCastExpr::ResultCategory Category =
- ImplicitCastExpr::RValue,
- const CXXCastPath *BasePath = 0);
-
- // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
- // functions and arrays to their respective pointers (C99 6.3.2.1).
- Expr *UsualUnaryConversions(Expr *&expr);
-
- // DefaultFunctionArrayConversion - converts functions and arrays
- // to their respective pointers (C99 6.3.2.1).
- void DefaultFunctionArrayConversion(Expr *&expr);
-
- // DefaultFunctionArrayLvalueConversion - converts functions and
- // arrays to their respective pointers and performs the
- // lvalue-to-rvalue conversion.
- void DefaultFunctionArrayLvalueConversion(Expr *&expr);
-
- // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
- // do not have a prototype. Integer promotions are performed on each
- // argument, and arguments that have type float are promoted to double.
- void DefaultArgumentPromotion(Expr *&Expr);
-
- // Used for emitting the right warning by DefaultVariadicArgumentPromotion
- enum VariadicCallType {
- VariadicFunction,
- VariadicBlock,
- VariadicMethod,
- VariadicConstructor,
- VariadicDoesNotApply
- };
-
- /// GatherArgumentsForCall - Collector argument expressions for various
- /// form of call prototypes.
- bool GatherArgumentsForCall(SourceLocation CallLoc,
- FunctionDecl *FDecl,
- const FunctionProtoType *Proto,
- unsigned FirstProtoArg,
- Expr **Args, unsigned NumArgs,
- llvm::SmallVector<Expr *, 8> &AllArgs,
- VariadicCallType CallType = VariadicDoesNotApply);
-
- // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
- // will warn if the resulting type is not a POD type.
- bool DefaultVariadicArgumentPromotion(Expr *&Expr, VariadicCallType CT,
- FunctionDecl *FDecl);
-
- // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
- // operands and then handles various conversions that are common to binary
- // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
- // routine returns the first non-arithmetic type found. The client is
- // responsible for emitting appropriate error diagnostics.
- QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr,
- bool isCompAssign = false);
-
- /// AssignConvertType - All of the 'assignment' semantic checks return this
- /// enum to indicate whether the assignment was allowed. These checks are
- /// done for simple assignments, as well as initialization, return from
- /// function, argument passing, etc. The query is phrased in terms of a
- /// source and destination type.
- enum AssignConvertType {
- /// Compatible - the types are compatible according to the standard.
- Compatible,
-
- /// PointerToInt - The assignment converts a pointer to an int, which we
- /// accept as an extension.
- PointerToInt,
-
- /// IntToPointer - The assignment converts an int to a pointer, which we
- /// accept as an extension.
- IntToPointer,
-
- /// FunctionVoidPointer - The assignment is between a function pointer and
- /// void*, which the standard doesn't allow, but we accept as an extension.
- FunctionVoidPointer,
-
- /// IncompatiblePointer - The assignment is between two pointers types that
- /// are not compatible, but we accept them as an extension.
- IncompatiblePointer,
-
- /// IncompatiblePointer - The assignment is between two pointers types which
- /// point to integers which have a different sign, but are otherwise identical.
- /// This is a subset of the above, but broken out because it's by far the most
- /// common case of incompatible pointers.
- IncompatiblePointerSign,
-
- /// CompatiblePointerDiscardsQualifiers - The assignment discards
- /// c/v/r qualifiers, which we accept as an extension.
- CompatiblePointerDiscardsQualifiers,
-
- /// IncompatibleNestedPointerQualifiers - The assignment is between two
- /// nested pointer types, and the qualifiers other than the first two
- /// levels differ e.g. char ** -> const char **, but we accept them as an
- /// extension.
- IncompatibleNestedPointerQualifiers,
-
- /// IncompatibleVectors - The assignment is between two vector types that
- /// have the same size, which we accept as an extension.
- IncompatibleVectors,
-
- /// IntToBlockPointer - The assignment converts an int to a block
- /// pointer. We disallow this.
- IntToBlockPointer,
-
- /// IncompatibleBlockPointer - The assignment is between two block
- /// pointers types that are not compatible.
- IncompatibleBlockPointer,
-
- /// IncompatibleObjCQualifiedId - The assignment is between a qualified
- /// id type and something else (that is incompatible with it). For example,
- /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
- IncompatibleObjCQualifiedId,
-
- /// Incompatible - We reject this conversion outright, it is invalid to
- /// represent it in the AST.
- Incompatible
- };
-
- /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
- /// assignment conversion type specified by ConvTy. This returns true if the
- /// conversion was invalid or false if the conversion was accepted.
- bool DiagnoseAssignmentResult(AssignConvertType ConvTy,
- SourceLocation Loc,
- QualType DstType, QualType SrcType,
- Expr *SrcExpr, AssignmentAction Action,
- bool *Complained = 0);
-
- /// CheckAssignmentConstraints - Perform type checking for assignment,
- /// argument passing, variable initialization, and function return values.
- /// This routine is only used by the following two methods. C99 6.5.16.
- AssignConvertType CheckAssignmentConstraints(QualType lhs, QualType rhs);
-
- // CheckSingleAssignmentConstraints - Currently used by
- // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking,
- // this routine performs the default function/array converions.
- AssignConvertType CheckSingleAssignmentConstraints(QualType lhs,
- Expr *&rExpr);
-
- // \brief If the lhs type is a transparent union, check whether we
- // can initialize the transparent union with the given expression.
- AssignConvertType CheckTransparentUnionArgumentConstraints(QualType lhs,
- Expr *&rExpr);
-
- // Helper function for CheckAssignmentConstraints (C99 6.5.16.1p1)
- AssignConvertType CheckPointerTypesForAssignment(QualType lhsType,
- QualType rhsType);
-
- AssignConvertType CheckObjCPointerTypesForAssignment(QualType lhsType,
- QualType rhsType);
-
- // Helper function for CheckAssignmentConstraints involving two
- // block pointer types.
- AssignConvertType CheckBlockPointerTypesForAssignment(QualType lhsType,
- QualType rhsType);
-
- bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType);
-
- bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
-
- bool PerformImplicitConversion(Expr *&From, QualType ToType,
- AssignmentAction Action,
- bool AllowExplicit = false);
- bool PerformImplicitConversion(Expr *&From, QualType ToType,
- AssignmentAction Action,
- bool AllowExplicit,
- ImplicitConversionSequence& ICS);
- bool PerformImplicitConversion(Expr *&From, QualType ToType,
- const ImplicitConversionSequence& ICS,
- AssignmentAction Action,
- bool IgnoreBaseAccess = false);
- bool PerformImplicitConversion(Expr *&From, QualType ToType,
- const StandardConversionSequence& SCS,
- AssignmentAction Action,bool IgnoreBaseAccess);
-
- /// the following "Check" methods will return a valid/converted QualType
- /// or a null QualType (indicating an error diagnostic was issued).
-
- /// type checking binary operators (subroutines of CreateBuiltinBinOp).
- QualType InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex);
- QualType CheckPointerToMemberOperands( // C++ 5.5
- Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isIndirect);
- QualType CheckMultiplyDivideOperands( // C99 6.5.5
- Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign,
- bool isDivide);
- QualType CheckRemainderOperands( // C99 6.5.5
- Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
- QualType CheckAdditionOperands( // C99 6.5.6
- Expr *&lex, Expr *&rex, SourceLocation OpLoc, QualType* CompLHSTy = 0);
- QualType CheckSubtractionOperands( // C99 6.5.6
- Expr *&lex, Expr *&rex, SourceLocation OpLoc, QualType* CompLHSTy = 0);
- QualType CheckShiftOperands( // C99 6.5.7
- Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
- QualType CheckCompareOperands( // C99 6.5.8/9
- Expr *&lex, Expr *&rex, SourceLocation OpLoc, unsigned Opc,
- bool isRelational);
- QualType CheckBitwiseOperands( // C99 6.5.[10...12]
- Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
- QualType CheckLogicalOperands( // C99 6.5.[13,14]
- Expr *&lex, Expr *&rex, SourceLocation OpLoc, unsigned Opc);
- // CheckAssignmentOperands is used for both simple and compound assignment.
- // For simple assignment, pass both expressions and a null converted type.
- // For compound assignment, pass both expressions and the converted type.
- QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
- Expr *lex, Expr *&rex, SourceLocation OpLoc, QualType convertedType);
- QualType CheckCommaOperands( // C99 6.5.17
- Expr *lex, Expr *&rex, SourceLocation OpLoc);
- QualType CheckConditionalOperands( // C99 6.5.15
- Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc);
- QualType CXXCheckConditionalOperands( // C++ 5.16
- Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc);
- QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2,
- bool *NonStandardCompositeType = 0);
-
- QualType FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS,
- SourceLocation questionLoc);
-
- /// type checking for vector binary operators.
- QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex);
- QualType CheckVectorCompareOperands(Expr *&lex, Expr *&rx,
- SourceLocation l, bool isRel);
-
- /// type checking unary operators (subroutines of ActOnUnaryOp).
- /// C99 6.5.3.1, 6.5.3.2, 6.5.3.4
- QualType CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc,
- bool isInc, bool isPrefix);
- QualType CheckAddressOfOperand(Expr *op, SourceLocation OpLoc);
- QualType CheckIndirectionOperand(Expr *op, SourceLocation OpLoc);
- QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc, bool isReal);
-
- /// type checking primary expressions.
- QualType CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc,
- const IdentifierInfo *Comp,
- SourceLocation CmpLoc);
-
- /// type checking declaration initializers (C99 6.7.8)
- bool CheckInitList(const InitializedEntity &Entity,
- InitListExpr *&InitList, QualType &DeclType);
- bool CheckForConstantInitializer(Expr *e, QualType t);
-
- // type checking C++ declaration initializers (C++ [dcl.init]).
-
- /// ReferenceCompareResult - Expresses the result of comparing two
- /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
- /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
- enum ReferenceCompareResult {
- /// Ref_Incompatible - The two types are incompatible, so direct
- /// reference binding is not possible.
- Ref_Incompatible = 0,
- /// Ref_Related - The two types are reference-related, which means
- /// that their unqualified forms (T1 and T2) are either the same
- /// or T1 is a base class of T2.
- Ref_Related,
- /// Ref_Compatible_With_Added_Qualification - The two types are
- /// reference-compatible with added qualification, meaning that
- /// they are reference-compatible and the qualifiers on T1 (cv1)
- /// are greater than the qualifiers on T2 (cv2).
- Ref_Compatible_With_Added_Qualification,
- /// Ref_Compatible - The two types are reference-compatible and
- /// have equivalent qualifiers (cv1 == cv2).
- Ref_Compatible
- };
-
- ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc,
- QualType T1, QualType T2,
- bool &DerivedToBase,
- bool &ObjCConversion);
-
- /// CheckCastTypes - Check type constraints for casting between types under
- /// C semantics, or forward to CXXCheckCStyleCast in C++.
- bool CheckCastTypes(SourceRange TyRange, QualType CastTy, Expr *&CastExpr,
- CastExpr::CastKind &Kind, CXXCastPath &BasePath,
- bool FunctionalStyle = false);
-
- // CheckVectorCast - check type constraints for vectors.
- // Since vectors are an extension, there are no C standard reference for this.
- // We allow casting between vectors and integer datatypes of the same size.
- // returns true if the cast is invalid
- bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
- CastExpr::CastKind &Kind);
-
- // CheckExtVectorCast - check type constraints for extended vectors.
- // Since vectors are an extension, there are no C standard reference for this.
- // We allow casting between vectors and integer datatypes of the same size,
- // or vectors and the element type of that vector.
- // returns true if the cast is invalid
- bool CheckExtVectorCast(SourceRange R, QualType VectorTy, Expr *&CastExpr,
- CastExpr::CastKind &Kind);
-
- /// CXXCheckCStyleCast - Check constraints of a C-style or function-style
- /// cast under C++ semantics.
- bool CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr,
- CastExpr::CastKind &Kind, CXXCastPath &BasePath,
- bool FunctionalStyle);
-
- /// CheckMessageArgumentTypes - Check types in an Obj-C message send.
- /// \param Method - May be null.
- /// \param [out] ReturnType - The return type of the send.
- /// \return true iff there were any incompatible types.
- bool CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs, Selector Sel,
- ObjCMethodDecl *Method, bool isClassMessage,
- SourceLocation lbrac, SourceLocation rbrac,
- QualType &ReturnType);
-
- /// CheckBooleanCondition - Diagnose problems involving the use of
- /// the given expression as a boolean condition (e.g. in an if
- /// statement). Also performs the standard function and array
- /// decays, possibly changing the input variable.
- ///
- /// \param Loc - A location associated with the condition, e.g. the
- /// 'if' keyword.
- /// \return true iff there were any errors
- bool CheckBooleanCondition(Expr *&CondExpr, SourceLocation Loc);
-
- virtual OwningExprResult ActOnBooleanCondition(Scope *S, SourceLocation Loc,
- ExprArg SubExpr);
-
- /// DiagnoseAssignmentAsCondition - Given that an expression is
- /// being used as a boolean condition, warn if it's an assignment.
- void DiagnoseAssignmentAsCondition(Expr *E);
-
- /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
- bool CheckCXXBooleanCondition(Expr *&CondExpr);
-
- /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have
- /// the specified width and sign. If an overflow occurs, detect it and emit
- /// the specified diagnostic.
- void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal,
- unsigned NewWidth, bool NewSign,
- SourceLocation Loc, unsigned DiagID);
-
- /// Checks that the Objective-C declaration is declared in the global scope.
- /// Emits an error and marks the declaration as invalid if it's not declared
- /// in the global scope.
- bool CheckObjCDeclScope(Decl *D);
-
- void InitBuiltinVaListType();
-
- /// VerifyIntegerConstantExpression - verifies that an expression is an ICE,
- /// and reports the appropriate diagnostics. Returns false on success.
- /// Can optionally return the value of the expression.
- bool VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result = 0);
-
- /// VerifyBitField - verifies that a bit field expression is an ICE and has
- /// the correct width, and that the field type is valid.
- /// Returns false on success.
- /// Can optionally return whether the bit-field is of width 0
- bool VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
- QualType FieldTy, const Expr *BitWidth,
- bool *ZeroWidth = 0);
-
- /// \name Code completion
- //@{
- virtual void CodeCompleteOrdinaryName(Scope *S,
- ParserCompletionContext CompletionContext);
- virtual void CodeCompleteExpression(Scope *S, QualType T,
- bool IntegralConstantExpression = false);
- virtual void CodeCompleteMemberReferenceExpr(Scope *S, ExprTy *Base,
- SourceLocation OpLoc,
- bool IsArrow);
- virtual void CodeCompleteTag(Scope *S, unsigned TagSpec);
- virtual void CodeCompleteCase(Scope *S);
- virtual void CodeCompleteCall(Scope *S, ExprTy *Fn,
- ExprTy **Args, unsigned NumArgs);
- virtual void CodeCompleteInitializer(Scope *S, DeclPtrTy D);
- virtual void CodeCompleteReturn(Scope *S);
- virtual void CodeCompleteAssignmentRHS(Scope *S, ExprTy *LHS);
-
- virtual void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
- bool EnteringContext);
- virtual void CodeCompleteUsing(Scope *S);
- virtual void CodeCompleteUsingDirective(Scope *S);
- virtual void CodeCompleteNamespaceDecl(Scope *S);
- virtual void CodeCompleteNamespaceAliasDecl(Scope *S);
- virtual void CodeCompleteOperatorName(Scope *S);
-
- virtual void CodeCompleteObjCAtDirective(Scope *S, DeclPtrTy ObjCImpDecl,
- bool InInterface);
- virtual void CodeCompleteObjCAtVisibility(Scope *S);
- virtual void CodeCompleteObjCAtStatement(Scope *S);
- virtual void CodeCompleteObjCAtExpression(Scope *S);
- virtual void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS);
- virtual void CodeCompleteObjCPropertyGetter(Scope *S, DeclPtrTy ClassDecl,
- DeclPtrTy *Methods,
- unsigned NumMethods);
- virtual void CodeCompleteObjCPropertySetter(Scope *S, DeclPtrTy ClassDecl,
- DeclPtrTy *Methods,
- unsigned NumMethods);
- virtual void CodeCompleteObjCMessageReceiver(Scope *S);
- virtual void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc,
- IdentifierInfo **SelIdents,
- unsigned NumSelIdents);
- virtual void CodeCompleteObjCClassMessage(Scope *S, TypeTy *Receiver,
- IdentifierInfo **SelIdents,
- unsigned NumSelIdents);
- virtual void CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver,
- IdentifierInfo **SelIdents,
- unsigned NumSelIdents);
- virtual void CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
- unsigned NumProtocols);
- virtual void CodeCompleteObjCProtocolDecl(Scope *S);
- virtual void CodeCompleteObjCInterfaceDecl(Scope *S);
- virtual void CodeCompleteObjCSuperclass(Scope *S,
- IdentifierInfo *ClassName,
- SourceLocation ClassNameLoc);
- virtual void CodeCompleteObjCImplementationDecl(Scope *S);
- virtual void CodeCompleteObjCInterfaceCategory(Scope *S,
- IdentifierInfo *ClassName,
- SourceLocation ClassNameLoc);
- virtual void CodeCompleteObjCImplementationCategory(Scope *S,
- IdentifierInfo *ClassName,
- SourceLocation ClassNameLoc);
- virtual void CodeCompleteObjCPropertyDefinition(Scope *S,
- DeclPtrTy ObjCImpDecl);
- virtual void CodeCompleteObjCPropertySynthesizeIvar(Scope *S,
- IdentifierInfo *PropertyName,
- DeclPtrTy ObjCImpDecl);
- virtual void CodeCompleteObjCMethodDecl(Scope *S,
- bool IsInstanceMethod,
- TypeTy *ReturnType,
- DeclPtrTy IDecl);
- virtual void CodeCompleteObjCMethodDeclSelector(Scope *S,
- bool IsInstanceMethod,
- bool AtParameterName,
- TypeTy *ReturnType,
- IdentifierInfo **SelIdents,
- unsigned NumSelIdents);
-
- //@}
-
- //===--------------------------------------------------------------------===//
- // Extra semantic analysis beyond the C type system
-
-public:
- SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL,
- unsigned ByteNo) const;
-
-private:
- bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall);
- bool CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall);
-
- bool CheckablePrintfAttr(const FormatAttr *Format, CallExpr *TheCall);
- bool CheckObjCString(Expr *Arg);
-
- Action::OwningExprResult CheckBuiltinFunctionCall(unsigned BuiltinID,
- CallExpr *TheCall);
- bool CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
- bool CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
-
- bool SemaBuiltinVAStart(CallExpr *TheCall);
- bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
- bool SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs);
-
-public:
- // Used by C++ template instantiation.
- Action::OwningExprResult SemaBuiltinShuffleVector(CallExpr *TheCall);
-
-private:
- bool SemaBuiltinPrefetch(CallExpr *TheCall);
- bool SemaBuiltinObjectSize(CallExpr *TheCall);
- bool SemaBuiltinLongjmp(CallExpr *TheCall);
- OwningExprResult SemaBuiltinAtomicOverloaded(OwningExprResult TheCallResult);
- bool SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum,
- llvm::APSInt &Result);
-
- bool SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall,
- bool HasVAListArg, unsigned format_idx,
- unsigned firstDataArg, bool isPrintf);
-
- void CheckFormatString(const StringLiteral *FExpr, const Expr *OrigFormatExpr,
- const CallExpr *TheCall, bool HasVAListArg,
- unsigned format_idx, unsigned firstDataArg,
- bool isPrintf);
-
- void CheckNonNullArguments(const NonNullAttr *NonNull,
- const CallExpr *TheCall);
-
- void CheckPrintfScanfArguments(const CallExpr *TheCall, bool HasVAListArg,
- unsigned format_idx, unsigned firstDataArg,
- bool isPrintf);
-
- void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
- SourceLocation ReturnLoc);
- void CheckFloatComparison(SourceLocation loc, Expr* lex, Expr* rex);
- void CheckImplicitConversions(Expr *E);
-};
-
-//===--------------------------------------------------------------------===//
-// Typed version of Parser::ExprArg (smart pointer for wrapping Expr pointers).
-template <typename T>
-class ExprOwningPtr : public Action::ExprArg {
-public:
- ExprOwningPtr(Sema *S, T *expr) : Action::ExprArg(*S, expr) {}
-
- void reset(T* p) { Action::ExprArg::operator=(p); }
- T* get() const { return static_cast<T*>(Action::ExprArg::get()); }
- T* take() { return static_cast<T*>(Action::ExprArg::take()); }
- T* release() { return take(); }
-
- T& operator*() const { return *get(); }
- T* operator->() const { return get(); }
-};
-
-} // end namespace clang
-
-#endif
Modified: cfe/trunk/lib/Sema/SemaAccess.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAccess.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaAccess.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAccess.cpp Thu Aug 12 15:07:10 2010
@@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "SemaInit.h"
-#include "Lookup.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Initialization.h"
+#include "clang/Sema/Lookup.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/DeclCXX.h"
Modified: cfe/trunk/lib/Sema/SemaAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAttr.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAttr.cpp Thu Aug 12 15:07:10 2010
@@ -12,8 +12,8 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "Lookup.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Lookup.h"
#include "clang/AST/Expr.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/Preprocessor.h"
Modified: cfe/trunk/lib/Sema/SemaCXXCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXCast.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXCast.cpp Thu Aug 12 15:07:10 2010
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "SemaInit.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Initialization.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/CXXInheritance.h"
Modified: cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp Thu Aug 12 15:07:10 2010
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "Lookup.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Lookup.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/ExprCXX.h"
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Aug 12 15:07:10 2010
@@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
+#include "clang/Sema/Sema.h"
#include "clang/Analysis/Analyses/FormatString.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/CharUnits.h"
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu Aug 12 15:07:10 2010
@@ -10,8 +10,8 @@
// This file defines the code-completion semantic actions.
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "Lookup.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Lookup.h"
#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/Sema/ExternalSemaSource.h"
#include "clang/AST/ExprCXX.h"
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Aug 12 15:07:10 2010
@@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "SemaInit.h"
-#include "Lookup.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Initialization.h"
+#include "clang/Sema/Lookup.h"
#include "clang/AST/APValue.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Aug 12 15:07:10 2010
@@ -11,7 +11,7 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
+#include "clang/Sema/Sema.h"
#include "TargetAttributesSema.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Aug 12 15:07:10 2010
@@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "SemaInit.h"
-#include "Lookup.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Initialization.h"
+#include "clang/Sema/Lookup.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/CharUnits.h"
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Aug 12 15:07:10 2010
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "Lookup.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Lookup.h"
#include "clang/Sema/ExternalSemaSource.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ASTContext.h"
Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Thu Aug 12 15:07:10 2010
@@ -11,7 +11,7 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
+#include "clang/Sema/Sema.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Aug 12 15:07:10 2010
@@ -11,10 +11,10 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "SemaInit.h"
-#include "Lookup.h"
-#include "AnalysisBasedWarnings.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Initialization.h"
+#include "clang/Sema/Lookup.h"
+#include "clang/Sema/AnalysisBasedWarnings.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/DeclObjC.h"
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Aug 12 15:07:10 2010
@@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "SemaInit.h"
-#include "Lookup.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Initialization.h"
+#include "clang/Sema/Lookup.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/ExprCXX.h"
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Thu Aug 12 15:07:10 2010
@@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "Lookup.h"
-#include "SemaInit.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Lookup.h"
+#include "clang/Sema/Initialization.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/ExprObjC.h"
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Aug 12 15:07:10 2010
@@ -15,9 +15,9 @@
//
//===----------------------------------------------------------------------===//
-#include "SemaInit.h"
-#include "Lookup.h"
-#include "Sema.h"
+#include "clang/Sema/Initialization.h"
+#include "clang/Sema/Lookup.h"
+#include "clang/Sema/Sema.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Parse/Designator.h"
#include "clang/AST/ASTContext.h"
Removed: cfe/trunk/lib/Sema/SemaInit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.h?rev=110944&view=auto
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.h (original)
+++ cfe/trunk/lib/Sema/SemaInit.h (removed)
@@ -1,780 +0,0 @@
-//===--- SemaInit.h - Semantic Analysis for Initializers --------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides supporting data types for initialization of objects.
-//
-//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_SEMA_INIT_H
-#define LLVM_CLANG_SEMA_INIT_H
-
-#include "SemaOverload.h"
-#include "clang/AST/Type.h"
-#include "clang/AST/UnresolvedSet.h"
-#include "clang/Parse/Action.h"
-#include "clang/Basic/SourceLocation.h"
-#include "llvm/ADT/PointerIntPair.h"
-#include "llvm/ADT/SmallVector.h"
-#include <cassert>
-
-namespace llvm {
- class raw_ostream;
-}
-
-namespace clang {
-
-class CXXBaseSpecifier;
-class DeclaratorDecl;
-class DeclaratorInfo;
-class FieldDecl;
-class FunctionDecl;
-class ParmVarDecl;
-class Sema;
-class TypeLoc;
-class VarDecl;
-
-/// \brief Describes an entity that is being initialized.
-class InitializedEntity {
-public:
- /// \brief Specifies the kind of entity being initialized.
- enum EntityKind {
- /// \brief The entity being initialized is a variable.
- EK_Variable,
- /// \brief The entity being initialized is a function parameter.
- EK_Parameter,
- /// \brief The entity being initialized is the result of a function call.
- EK_Result,
- /// \brief The entity being initialized is an exception object that
- /// is being thrown.
- EK_Exception,
- /// \brief The entity being initialized is a non-static data member
- /// subobject.
- EK_Member,
- /// \brief The entity being initialized is an element of an array.
- EK_ArrayElement,
- /// \brief The entity being initialized is an object (or array of
- /// objects) allocated via new.
- EK_New,
- /// \brief The entity being initialized is a temporary object.
- EK_Temporary,
- /// \brief The entity being initialized is a base member subobject.
- EK_Base,
- /// \brief The entity being initialized is an element of a vector.
- /// or vector.
- EK_VectorElement,
- /// \brief The entity being initialized is a field of block descriptor for
- /// the copied-in c++ object.
- EK_BlockElement
- };
-
-private:
- /// \brief The kind of entity being initialized.
- EntityKind Kind;
-
- /// \brief If non-NULL, the parent entity in which this
- /// initialization occurs.
- const InitializedEntity *Parent;
-
- /// \brief The type of the object or reference being initialized.
- QualType Type;
-
- union {
- /// \brief When Kind == EK_Variable, EK_Parameter, or EK_Member,
- /// the VarDecl, ParmVarDecl, or FieldDecl, respectively.
- DeclaratorDecl *VariableOrMember;
-
- struct {
- /// \brief When Kind == EK_Result, EK_Exception, or EK_New, the
- /// location of the 'return', 'throw', or 'new' keyword,
- /// respectively. When Kind == EK_Temporary, the location where
- /// the temporary is being created.
- unsigned Location;
-
- /// \brief Whether the
- bool NRVO;
- } LocAndNRVO;
-
- /// \brief When Kind == EK_Base, the base specifier that provides the
- /// base class. The lower bit specifies whether the base is an inherited
- /// virtual base.
- uintptr_t Base;
-
- /// \brief When Kind == EK_ArrayElement or EK_VectorElement, the
- /// index of the array or vector element being initialized.
- unsigned Index;
- };
-
- InitializedEntity() { }
-
- /// \brief Create the initialization entity for a variable.
- InitializedEntity(VarDecl *Var)
- : Kind(EK_Variable), Parent(0), Type(Var->getType()),
- VariableOrMember(reinterpret_cast<DeclaratorDecl*>(Var)) { }
-
- /// \brief Create the initialization entity for a parameter.
- InitializedEntity(ParmVarDecl *Parm)
- : Kind(EK_Parameter), Parent(0), Type(Parm->getType().getUnqualifiedType()),
- VariableOrMember(reinterpret_cast<DeclaratorDecl*>(Parm)) { }
-
- /// \brief Create the initialization entity for the result of a
- /// function, throwing an object, performing an explicit cast, or
- /// initializing a parameter for which there is no declaration.
- InitializedEntity(EntityKind Kind, SourceLocation Loc, QualType Type,
- bool NRVO = false)
- : Kind(Kind), Parent(0), Type(Type)
- {
- LocAndNRVO.Location = Loc.getRawEncoding();
- LocAndNRVO.NRVO = NRVO;
- }
-
- /// \brief Create the initialization entity for a member subobject.
- InitializedEntity(FieldDecl *Member, const InitializedEntity *Parent)
- : Kind(EK_Member), Parent(Parent), Type(Member->getType()),
- VariableOrMember(reinterpret_cast<DeclaratorDecl*>(Member)) { }
-
- /// \brief Create the initialization entity for an array element.
- InitializedEntity(ASTContext &Context, unsigned Index,
- const InitializedEntity &Parent);
-
-public:
- /// \brief Create the initialization entity for a variable.
- static InitializedEntity InitializeVariable(VarDecl *Var) {
- return InitializedEntity(Var);
- }
-
- /// \brief Create the initialization entity for a parameter.
- static InitializedEntity InitializeParameter(ParmVarDecl *Parm) {
- return InitializedEntity(Parm);
- }
-
- /// \brief Create the initialization entity for a parameter that is
- /// only known by its type.
- static InitializedEntity InitializeParameter(QualType Type) {
- InitializedEntity Entity;
- Entity.Kind = EK_Parameter;
- Entity.Type = Type;
- Entity.Parent = 0;
- Entity.VariableOrMember = 0;
- return Entity;
- }
-
- /// \brief Create the initialization entity for the result of a function.
- static InitializedEntity InitializeResult(SourceLocation ReturnLoc,
- QualType Type, bool NRVO) {
- return InitializedEntity(EK_Result, ReturnLoc, Type, NRVO);
- }
-
- static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc,
- QualType Type, bool NRVO) {
- return InitializedEntity(EK_BlockElement, BlockVarLoc, Type, NRVO);
- }
-
- /// \brief Create the initialization entity for an exception object.
- static InitializedEntity InitializeException(SourceLocation ThrowLoc,
- QualType Type, bool NRVO) {
- return InitializedEntity(EK_Exception, ThrowLoc, Type, NRVO);
- }
-
- /// \brief Create the initialization entity for an object allocated via new.
- static InitializedEntity InitializeNew(SourceLocation NewLoc, QualType Type) {
- return InitializedEntity(EK_New, NewLoc, Type);
- }
-
- /// \brief Create the initialization entity for a temporary.
- static InitializedEntity InitializeTemporary(QualType Type) {
- return InitializedEntity(EK_Temporary, SourceLocation(), Type);
- }
-
- /// \brief Create the initialization entity for a base class subobject.
- static InitializedEntity InitializeBase(ASTContext &Context,
- CXXBaseSpecifier *Base,
- bool IsInheritedVirtualBase);
-
- /// \brief Create the initialization entity for a member subobject.
- static InitializedEntity InitializeMember(FieldDecl *Member,
- const InitializedEntity *Parent = 0) {
- return InitializedEntity(Member, Parent);
- }
-
- /// \brief Create the initialization entity for an array element.
- static InitializedEntity InitializeElement(ASTContext &Context,
- unsigned Index,
- const InitializedEntity &Parent) {
- return InitializedEntity(Context, Index, Parent);
- }
-
- /// \brief Determine the kind of initialization.
- EntityKind getKind() const { return Kind; }
-
- /// \brief Retrieve the parent of the entity being initialized, when
- /// the initialization itself is occuring within the context of a
- /// larger initialization.
- const InitializedEntity *getParent() const { return Parent; }
-
- /// \brief Retrieve type being initialized.
- QualType getType() const { return Type; }
-
- /// \brief Retrieve the name of the entity being initialized.
- DeclarationName getName() const;
-
- /// \brief Retrieve the variable, parameter, or field being
- /// initialized.
- DeclaratorDecl *getDecl() const;
-
- /// \brief Determine whether this initialization allows the named return
- /// value optimization, which also applies to thrown objects.
- bool allowsNRVO() const;
-
- /// \brief Retrieve the base specifier.
- CXXBaseSpecifier *getBaseSpecifier() const {
- assert(getKind() == EK_Base && "Not a base specifier");
- return reinterpret_cast<CXXBaseSpecifier *>(Base & ~0x1);
- }
-
- /// \brief Return whether the base is an inherited virtual base.
- bool isInheritedVirtualBase() const {
- assert(getKind() == EK_Base && "Not a base specifier");
- return Base & 0x1;
- }
-
- /// \brief Determine the location of the 'return' keyword when initializing
- /// the result of a function call.
- SourceLocation getReturnLoc() const {
- assert(getKind() == EK_Result && "No 'return' location!");
- return SourceLocation::getFromRawEncoding(LocAndNRVO.Location);
- }
-
- /// \brief Determine the location of the 'throw' keyword when initializing
- /// an exception object.
- SourceLocation getThrowLoc() const {
- assert(getKind() == EK_Exception && "No 'throw' location!");
- return SourceLocation::getFromRawEncoding(LocAndNRVO.Location);
- }
-
- /// \brief If this is already the initializer for an array or vector
- /// element, sets the element index.
- void setElementIndex(unsigned Index) {
- assert(getKind() == EK_ArrayElement || getKind() == EK_VectorElement);
- this->Index = Index;
- }
-};
-
-/// \brief Describes the kind of initialization being performed, along with
-/// location information for tokens related to the initialization (equal sign,
-/// parentheses).
-class InitializationKind {
-public:
- /// \brief The kind of initialization being performed.
- enum InitKind {
- IK_Direct, ///< Direct initialization
- IK_Copy, ///< Copy initialization
- IK_Default, ///< Default initialization
- IK_Value ///< Value initialization
- };
-
-private:
- /// \brief The kind of initialization that we're storing.
- enum StoredInitKind {
- SIK_Direct = IK_Direct, ///< Direct initialization
- SIK_Copy = IK_Copy, ///< Copy initialization
- SIK_Default = IK_Default, ///< Default initialization
- SIK_Value = IK_Value, ///< Value initialization
- SIK_ImplicitValue, ///< Implicit value initialization
- SIK_DirectCast, ///< Direct initialization due to a cast
- /// \brief Direct initialization due to a C-style or functional cast.
- SIK_DirectCStyleOrFunctionalCast
- };
-
- /// \brief The kind of initialization being performed.
- StoredInitKind Kind;
-
- /// \brief The source locations involved in the initialization.
- SourceLocation Locations[3];
-
- InitializationKind(StoredInitKind Kind, SourceLocation Loc1,
- SourceLocation Loc2, SourceLocation Loc3)
- : Kind(Kind)
- {
- Locations[0] = Loc1;
- Locations[1] = Loc2;
- Locations[2] = Loc3;
- }
-
-public:
- /// \brief Create a direct initialization.
- static InitializationKind CreateDirect(SourceLocation InitLoc,
- SourceLocation LParenLoc,
- SourceLocation RParenLoc) {
- return InitializationKind(SIK_Direct, InitLoc, LParenLoc, RParenLoc);
- }
-
- /// \brief Create a direct initialization due to a cast.
- static InitializationKind CreateCast(SourceRange TypeRange,
- bool IsCStyleCast) {
- return InitializationKind(IsCStyleCast? SIK_DirectCStyleOrFunctionalCast
- : SIK_DirectCast,
- TypeRange.getBegin(), TypeRange.getBegin(),
- TypeRange.getEnd());
- }
-
- /// \brief Create a copy initialization.
- static InitializationKind CreateCopy(SourceLocation InitLoc,
- SourceLocation EqualLoc) {
- return InitializationKind(SIK_Copy, InitLoc, EqualLoc, EqualLoc);
- }
-
- /// \brief Create a default initialization.
- static InitializationKind CreateDefault(SourceLocation InitLoc) {
- return InitializationKind(SIK_Default, InitLoc, InitLoc, InitLoc);
- }
-
- /// \brief Create a value initialization.
- static InitializationKind CreateValue(SourceLocation InitLoc,
- SourceLocation LParenLoc,
- SourceLocation RParenLoc,
- bool isImplicit = false) {
- return InitializationKind(isImplicit? SIK_ImplicitValue : SIK_Value,
- InitLoc, LParenLoc, RParenLoc);
- }
-
- /// \brief Determine the initialization kind.
- InitKind getKind() const {
- if (Kind > SIK_ImplicitValue)
- return IK_Direct;
- if (Kind == SIK_ImplicitValue)
- return IK_Value;
-
- return (InitKind)Kind;
- }
-
- /// \brief Determine whether this initialization is an explicit cast.
- bool isExplicitCast() const {
- return Kind == SIK_DirectCast || Kind == SIK_DirectCStyleOrFunctionalCast;
- }
-
- /// \brief Determine whether this initialization is a C-style cast.
- bool isCStyleOrFunctionalCast() const {
- return Kind == SIK_DirectCStyleOrFunctionalCast;
- }
-
- /// \brief Determine whether this initialization is an implicit
- /// value-initialization, e.g., as occurs during aggregate
- /// initialization.
- bool isImplicitValueInit() const { return Kind == SIK_ImplicitValue; }
-
- /// \brief Retrieve the location at which initialization is occurring.
- SourceLocation getLocation() const { return Locations[0]; }
-
- /// \brief Retrieve the source range that covers the initialization.
- SourceRange getRange() const {
- return SourceRange(Locations[0], Locations[2]);
- }
-
- /// \brief Retrieve the location of the equal sign for copy initialization
- /// (if present).
- SourceLocation getEqualLoc() const {
- assert(Kind == SIK_Copy && "Only copy initialization has an '='");
- return Locations[1];
- }
-
- bool isCopyInit() const { return Kind == SIK_Copy; }
-
- /// \brief Retrieve the source range containing the locations of the open
- /// and closing parentheses for value and direct initializations.
- SourceRange getParenRange() const {
- assert((getKind() == IK_Direct || Kind == SIK_Value) &&
- "Only direct- and value-initialization have parentheses");
- return SourceRange(Locations[1], Locations[2]);
- }
-};
-
-/// \brief Describes the sequence of initializations required to initialize
-/// a given object or reference with a set of arguments.
-class InitializationSequence {
-public:
- /// \brief Describes the kind of initialization sequence computed.
- ///
- /// FIXME: Much of this information is in the initialization steps... why is
- /// it duplicated here?
- enum SequenceKind {
- /// \brief A failed initialization sequence. The failure kind tells what
- /// happened.
- FailedSequence = 0,
-
- /// \brief A dependent initialization, which could not be
- /// type-checked due to the presence of dependent types or
- /// dependently-type expressions.
- DependentSequence,
-
- /// \brief A user-defined conversion sequence.
- UserDefinedConversion,
-
- /// \brief A constructor call.
- ConstructorInitialization,
-
- /// \brief A reference binding.
- ReferenceBinding,
-
- /// \brief List initialization
- ListInitialization,
-
- /// \brief Zero-initialization.
- ZeroInitialization,
-
- /// \brief No initialization required.
- NoInitialization,
-
- /// \brief Standard conversion sequence.
- StandardConversion,
-
- /// \brief C conversion sequence.
- CAssignment,
-
- /// \brief String initialization
- StringInit
- };
-
- /// \brief Describes the kind of a particular step in an initialization
- /// sequence.
- enum StepKind {
- /// \brief Resolve the address of an overloaded function to a specific
- /// function declaration.
- SK_ResolveAddressOfOverloadedFunction,
- /// \brief Perform a derived-to-base cast, producing an rvalue.
- SK_CastDerivedToBaseRValue,
- /// \brief Perform a derived-to-base cast, producing an xvalue.
- SK_CastDerivedToBaseXValue,
- /// \brief Perform a derived-to-base cast, producing an lvalue.
- SK_CastDerivedToBaseLValue,
- /// \brief Reference binding to an lvalue.
- SK_BindReference,
- /// \brief Reference binding to a temporary.
- SK_BindReferenceToTemporary,
- /// \brief An optional copy of a temporary object to another
- /// temporary object, which is permitted (but not required) by
- /// C++98/03 but not C++0x.
- SK_ExtraneousCopyToTemporary,
- /// \brief Perform a user-defined conversion, either via a conversion
- /// function or via a constructor.
- SK_UserConversion,
- /// \brief Perform a qualification conversion, producing an rvalue.
- SK_QualificationConversionRValue,
- /// \brief Perform a qualification conversion, producing an xvalue.
- SK_QualificationConversionXValue,
- /// \brief Perform a qualification conversion, producing an lvalue.
- SK_QualificationConversionLValue,
- /// \brief Perform an implicit conversion sequence.
- SK_ConversionSequence,
- /// \brief Perform list-initialization
- SK_ListInitialization,
- /// \brief Perform initialization via a constructor.
- SK_ConstructorInitialization,
- /// \brief Zero-initialize the object
- SK_ZeroInitialization,
- /// \brief C assignment
- SK_CAssignment,
- /// \brief Initialization by string
- SK_StringInit,
- /// \brief An initialization that "converts" an Objective-C object
- /// (not a point to an object) to another Objective-C object type.
- SK_ObjCObjectConversion
- };
-
- /// \brief A single step in the initialization sequence.
- class Step {
- public:
- /// \brief The kind of conversion or initialization step we are taking.
- StepKind Kind;
-
- // \brief The type that results from this initialization.
- QualType Type;
-
- union {
- /// \brief When Kind == SK_ResolvedOverloadedFunction or Kind ==
- /// SK_UserConversion, the function that the expression should be
- /// resolved to or the conversion function to call, respectively.
- ///
- /// Always a FunctionDecl.
- /// For conversion decls, the naming class is the source type.
- /// For construct decls, the naming class is the target type.
- struct {
- FunctionDecl *Function;
- DeclAccessPair FoundDecl;
- } Function;
-
- /// \brief When Kind = SK_ConversionSequence, the implicit conversion
- /// sequence
- ImplicitConversionSequence *ICS;
- };
-
- void Destroy();
- };
-
-private:
- /// \brief The kind of initialization sequence computed.
- enum SequenceKind SequenceKind;
-
- /// \brief Steps taken by this initialization.
- llvm::SmallVector<Step, 4> Steps;
-
-public:
- /// \brief Describes why initialization failed.
- enum FailureKind {
- /// \brief Too many initializers provided for a reference.
- FK_TooManyInitsForReference,
- /// \brief Array must be initialized with an initializer list.
- FK_ArrayNeedsInitList,
- /// \brief Array must be initialized with an initializer list or a
- /// string literal.
- FK_ArrayNeedsInitListOrStringLiteral,
- /// \brief Cannot resolve the address of an overloaded function.
- FK_AddressOfOverloadFailed,
- /// \brief Overloading due to reference initialization failed.
- FK_ReferenceInitOverloadFailed,
- /// \brief Non-const lvalue reference binding to a temporary.
- FK_NonConstLValueReferenceBindingToTemporary,
- /// \brief Non-const lvalue reference binding to an lvalue of unrelated
- /// type.
- FK_NonConstLValueReferenceBindingToUnrelated,
- /// \brief Rvalue reference binding to an lvalue.
- FK_RValueReferenceBindingToLValue,
- /// \brief Reference binding drops qualifiers.
- FK_ReferenceInitDropsQualifiers,
- /// \brief Reference binding failed.
- FK_ReferenceInitFailed,
- /// \brief Implicit conversion failed.
- FK_ConversionFailed,
- /// \brief Too many initializers for scalar
- FK_TooManyInitsForScalar,
- /// \brief Reference initialization from an initializer list
- FK_ReferenceBindingToInitList,
- /// \brief Initialization of some unused destination type with an
- /// initializer list.
- FK_InitListBadDestinationType,
- /// \brief Overloading for a user-defined conversion failed.
- FK_UserConversionOverloadFailed,
- /// \brief Overloaded for initialization by constructor failed.
- FK_ConstructorOverloadFailed,
- /// \brief Default-initialization of a 'const' object.
- FK_DefaultInitOfConst,
- /// \brief Initialization of an incomplete type.
- FK_Incomplete
- };
-
-private:
- /// \brief The reason why initialization failued.
- FailureKind Failure;
-
- /// \brief The failed result of overload resolution.
- OverloadingResult FailedOverloadResult;
-
- /// \brief The candidate set created when initialization failed.
- OverloadCandidateSet FailedCandidateSet;
-
- /// \brief Prints a follow-up note that highlights the location of
- /// the initialized entity, if it's remote.
- void PrintInitLocationNote(Sema &S, const InitializedEntity &Entity);
-
-public:
- /// \brief Try to perform initialization of the given entity, creating a
- /// record of the steps required to perform the initialization.
- ///
- /// The generated initialization sequence will either contain enough
- /// information to diagnose
- ///
- /// \param S the semantic analysis object.
- ///
- /// \param Entity the entity being initialized.
- ///
- /// \param Kind the kind of initialization being performed.
- ///
- /// \param Args the argument(s) provided for initialization.
- ///
- /// \param NumArgs the number of arguments provided for initialization.
- InitializationSequence(Sema &S,
- const InitializedEntity &Entity,
- const InitializationKind &Kind,
- Expr **Args,
- unsigned NumArgs);
-
- ~InitializationSequence();
-
- /// \brief Perform the actual initialization of the given entity based on
- /// the computed initialization sequence.
- ///
- /// \param S the semantic analysis object.
- ///
- /// \param Entity the entity being initialized.
- ///
- /// \param Kind the kind of initialization being performed.
- ///
- /// \param Args the argument(s) provided for initialization, ownership of
- /// which is transfered into the routine.
- ///
- /// \param ResultType if non-NULL, will be set to the type of the
- /// initialized object, which is the type of the declaration in most
- /// cases. However, when the initialized object is a variable of
- /// incomplete array type and the initializer is an initializer
- /// list, this type will be set to the completed array type.
- ///
- /// \returns an expression that performs the actual object initialization, if
- /// the initialization is well-formed. Otherwise, emits diagnostics
- /// and returns an invalid expression.
- Action::OwningExprResult Perform(Sema &S,
- const InitializedEntity &Entity,
- const InitializationKind &Kind,
- Action::MultiExprArg Args,
- QualType *ResultType = 0);
-
- /// \brief Diagnose an potentially-invalid initialization sequence.
- ///
- /// \returns true if the initialization sequence was ill-formed,
- /// false otherwise.
- bool Diagnose(Sema &S,
- const InitializedEntity &Entity,
- const InitializationKind &Kind,
- Expr **Args, unsigned NumArgs);
-
- /// \brief Determine the kind of initialization sequence computed.
- enum SequenceKind getKind() const { return SequenceKind; }
-
- /// \brief Set the kind of sequence computed.
- void setSequenceKind(enum SequenceKind SK) { SequenceKind = SK; }
-
- /// \brief Determine whether the initialization sequence is valid.
- operator bool() const { return SequenceKind != FailedSequence; }
-
- typedef llvm::SmallVector<Step, 4>::const_iterator step_iterator;
- step_iterator step_begin() const { return Steps.begin(); }
- step_iterator step_end() const { return Steps.end(); }
-
- /// \brief Determine whether this initialization is a direct reference
- /// binding (C++ [dcl.init.ref]).
- bool isDirectReferenceBinding() const;
-
- /// \brief Determine whether this initialization failed due to an ambiguity.
- bool isAmbiguous() const;
-
- /// \brief Determine whether this initialization is direct call to a
- /// constructor.
- bool isConstructorInitialization() const;
-
- /// \brief Add a new step in the initialization that resolves the address
- /// of an overloaded function to a specific function declaration.
- ///
- /// \param Function the function to which the overloaded function reference
- /// resolves.
- void AddAddressOverloadResolutionStep(FunctionDecl *Function,
- DeclAccessPair Found);
-
- /// \brief Add a new step in the initialization that performs a derived-to-
- /// base cast.
- ///
- /// \param BaseType the base type to which we will be casting.
- ///
- /// \param IsLValue true if the result of this cast will be treated as
- /// an lvalue.
- void AddDerivedToBaseCastStep(QualType BaseType,
- ImplicitCastExpr::ResultCategory Category);
-
- /// \brief Add a new step binding a reference to an object.
- ///
- /// \param BindingTemporary True if we are binding a reference to a temporary
- /// object (thereby extending its lifetime); false if we are binding to an
- /// lvalue or an lvalue treated as an rvalue.
- ///
- /// \param UnnecessaryCopy True if we should check for a copy
- /// constructor for a completely unnecessary but
- void AddReferenceBindingStep(QualType T, bool BindingTemporary);
-
- /// \brief Add a new step that makes an extraneous copy of the input
- /// to a temporary of the same class type.
- ///
- /// This extraneous copy only occurs during reference binding in
- /// C++98/03, where we are permitted (but not required) to introduce
- /// an extra copy. At a bare minimum, we must check that we could
- /// call the copy constructor, and produce a diagnostic if the copy
- /// constructor is inaccessible or no copy constructor matches.
- //
- /// \param T The type of the temporary being created.
- void AddExtraneousCopyToTemporary(QualType T);
-
- /// \brief Add a new step invoking a conversion function, which is either
- /// a constructor or a conversion function.
- void AddUserConversionStep(FunctionDecl *Function,
- DeclAccessPair FoundDecl,
- QualType T);
-
- /// \brief Add a new step that performs a qualification conversion to the
- /// given type.
- void AddQualificationConversionStep(QualType Ty,
- ImplicitCastExpr::ResultCategory Category);
-
- /// \brief Add a new step that applies an implicit conversion sequence.
- void AddConversionSequenceStep(const ImplicitConversionSequence &ICS,
- QualType T);
-
- /// \brief Add a list-initialiation step
- void AddListInitializationStep(QualType T);
-
- /// \brief Add a constructor-initialization step.
- void AddConstructorInitializationStep(CXXConstructorDecl *Constructor,
- AccessSpecifier Access,
- QualType T);
-
- /// \brief Add a zero-initialization step.
- void AddZeroInitializationStep(QualType T);
-
- /// \brief Add a C assignment step.
- //
- // FIXME: It isn't clear whether this should ever be needed;
- // ideally, we would handle everything needed in C in the common
- // path. However, that isn't the case yet.
- void AddCAssignmentStep(QualType T);
-
- /// \brief Add a string init step.
- void AddStringInitStep(QualType T);
-
- /// \brief Add an Objective-C object conversion step, which is
- /// always a no-op.
- void AddObjCObjectConversionStep(QualType T);
-
- /// \brief Note that this initialization sequence failed.
- void SetFailed(FailureKind Failure) {
- SequenceKind = FailedSequence;
- this->Failure = Failure;
- }
-
- /// \brief Note that this initialization sequence failed due to failed
- /// overload resolution.
- void SetOverloadFailure(FailureKind Failure, OverloadingResult Result);
-
- /// \brief Retrieve a reference to the candidate set when overload
- /// resolution fails.
- OverloadCandidateSet &getFailedCandidateSet() {
- return FailedCandidateSet;
- }
-
- /// \brief Determine why initialization failed.
- FailureKind getFailureKind() const {
- assert(getKind() == FailedSequence && "Not an initialization failure!");
- return Failure;
- }
-
- /// \brief Dump a representation of this initialization sequence to
- /// the given stream, for debugging purposes.
- void dump(llvm::raw_ostream &OS) const;
-
- /// \brief Dump a representation of this initialization sequence to
- /// standard error, for debugging purposes.
- void dump() const;
-};
-
-} // end namespace clang
-
-#endif // LLVM_CLANG_SEMA_INIT_H
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Thu Aug 12 15:07:10 2010
@@ -11,8 +11,8 @@
// Objective-C++.
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "Lookup.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Lookup.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/Decl.h"
Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Thu Aug 12 15:07:10 2010
@@ -12,8 +12,8 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "SemaInit.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Initialization.h"
#include "clang/AST/ExprObjC.h"
using namespace clang;
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Aug 12 15:07:10 2010
@@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "Lookup.h"
-#include "SemaInit.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Lookup.h"
+#include "clang/Sema/Initialization.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/AST/ASTContext.h"
Removed: cfe/trunk/lib/Sema/SemaOverload.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.h?rev=110944&view=auto
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.h (original)
+++ cfe/trunk/lib/Sema/SemaOverload.h (removed)
@@ -1,617 +0,0 @@
-//===--- Overload.h - C++ Overloading ---------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the data structures and types used in C++
-// overload resolution.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_SEMA_OVERLOAD_H
-#define LLVM_CLANG_SEMA_OVERLOAD_H
-
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclTemplate.h"
-#include "clang/AST/Expr.h"
-#include "clang/AST/TemplateBase.h"
-#include "clang/AST/Type.h"
-#include "clang/AST/UnresolvedSet.h"
-#include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/ADT/SmallVector.h"
-
-namespace clang {
- class ASTContext;
- class CXXConstructorDecl;
- class CXXConversionDecl;
- class FunctionDecl;
-
- /// OverloadingResult - Capture the result of performing overload
- /// resolution.
- enum OverloadingResult {
- OR_Success, ///< Overload resolution succeeded.
- OR_No_Viable_Function, ///< No viable function found.
- OR_Ambiguous, ///< Ambiguous candidates found.
- OR_Deleted ///< Succeeded, but refers to a deleted function.
- };
-
- /// ImplicitConversionKind - The kind of implicit conversion used to
- /// convert an argument to a parameter's type. The enumerator values
- /// match with Table 9 of (C++ 13.3.3.1.1) and are listed such that
- /// better conversion kinds have smaller values.
- enum ImplicitConversionKind {
- ICK_Identity = 0, ///< Identity conversion (no conversion)
- ICK_Lvalue_To_Rvalue, ///< Lvalue-to-rvalue conversion (C++ 4.1)
- ICK_Array_To_Pointer, ///< Array-to-pointer conversion (C++ 4.2)
- ICK_Function_To_Pointer, ///< Function-to-pointer (C++ 4.3)
- ICK_NoReturn_Adjustment, ///< Removal of noreturn from a type (Clang)
- ICK_Qualification, ///< Qualification conversions (C++ 4.4)
- ICK_Integral_Promotion, ///< Integral promotions (C++ 4.5)
- ICK_Floating_Promotion, ///< Floating point promotions (C++ 4.6)
- ICK_Complex_Promotion, ///< Complex promotions (Clang extension)
- ICK_Integral_Conversion, ///< Integral conversions (C++ 4.7)
- ICK_Floating_Conversion, ///< Floating point conversions (C++ 4.8)
- ICK_Complex_Conversion, ///< Complex conversions (C99 6.3.1.6)
- ICK_Floating_Integral, ///< Floating-integral conversions (C++ 4.9)
- ICK_Pointer_Conversion, ///< Pointer conversions (C++ 4.10)
- ICK_Pointer_Member, ///< Pointer-to-member conversions (C++ 4.11)
- ICK_Boolean_Conversion, ///< Boolean conversions (C++ 4.12)
- ICK_Compatible_Conversion, ///< Conversions between compatible types in C99
- ICK_Derived_To_Base, ///< Derived-to-base (C++ [over.best.ics])
- ICK_Vector_Conversion, ///< Vector conversions
- ICK_Vector_Splat, ///< A vector splat from an arithmetic type
- ICK_Complex_Real, ///< Complex-real conversions (C99 6.3.1.7)
- ICK_Num_Conversion_Kinds ///< The number of conversion kinds
- };
-
- /// ImplicitConversionCategory - The category of an implicit
- /// conversion kind. The enumerator values match with Table 9 of
- /// (C++ 13.3.3.1.1) and are listed such that better conversion
- /// categories have smaller values.
- enum ImplicitConversionCategory {
- ICC_Identity = 0, ///< Identity
- ICC_Lvalue_Transformation, ///< Lvalue transformation
- ICC_Qualification_Adjustment, ///< Qualification adjustment
- ICC_Promotion, ///< Promotion
- ICC_Conversion ///< Conversion
- };
-
- ImplicitConversionCategory
- GetConversionCategory(ImplicitConversionKind Kind);
-
- /// ImplicitConversionRank - The rank of an implicit conversion
- /// kind. The enumerator values match with Table 9 of (C++
- /// 13.3.3.1.1) and are listed such that better conversion ranks
- /// have smaller values.
- enum ImplicitConversionRank {
- ICR_Exact_Match = 0, ///< Exact Match
- ICR_Promotion, ///< Promotion
- ICR_Conversion, ///< Conversion
- ICR_Complex_Real_Conversion ///< Complex <-> Real conversion
- };
-
- ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind);
-
- /// StandardConversionSequence - represents a standard conversion
- /// sequence (C++ 13.3.3.1.1). A standard conversion sequence
- /// contains between zero and three conversions. If a particular
- /// conversion is not needed, it will be set to the identity conversion
- /// (ICK_Identity). Note that the three conversions are
- /// specified as separate members (rather than in an array) so that
- /// we can keep the size of a standard conversion sequence to a
- /// single word.
- struct StandardConversionSequence {
- /// First -- The first conversion can be an lvalue-to-rvalue
- /// conversion, array-to-pointer conversion, or
- /// function-to-pointer conversion.
- ImplicitConversionKind First : 8;
-
- /// Second - The second conversion can be an integral promotion,
- /// floating point promotion, integral conversion, floating point
- /// conversion, floating-integral conversion, pointer conversion,
- /// pointer-to-member conversion, or boolean conversion.
- ImplicitConversionKind Second : 8;
-
- /// Third - The third conversion can be a qualification conversion.
- ImplicitConversionKind Third : 8;
-
- /// Deprecated - Whether this the deprecated conversion of a
- /// string literal to a pointer to non-const character data
- /// (C++ 4.2p2).
- bool DeprecatedStringLiteralToCharPtr : 1;
-
- /// IncompatibleObjC - Whether this is an Objective-C conversion
- /// that we should warn about (if we actually use it).
- bool IncompatibleObjC : 1;
-
- /// ReferenceBinding - True when this is a reference binding
- /// (C++ [over.ics.ref]).
- bool ReferenceBinding : 1;
-
- /// DirectBinding - True when this is a reference binding that is a
- /// direct binding (C++ [dcl.init.ref]).
- bool DirectBinding : 1;
-
- /// RRefBinding - True when this is a reference binding of an rvalue
- /// reference to an rvalue (C++0x [over.ics.rank]p3b4).
- bool RRefBinding : 1;
-
- /// FromType - The type that this conversion is converting
- /// from. This is an opaque pointer that can be translated into a
- /// QualType.
- void *FromTypePtr;
-
- /// ToType - The types that this conversion is converting to in
- /// each step. This is an opaque pointer that can be translated
- /// into a QualType.
- void *ToTypePtrs[3];
-
- /// CopyConstructor - The copy constructor that is used to perform
- /// this conversion, when the conversion is actually just the
- /// initialization of an object via copy constructor. Such
- /// conversions are either identity conversions or derived-to-base
- /// conversions.
- CXXConstructorDecl *CopyConstructor;
-
- void setFromType(QualType T) { FromTypePtr = T.getAsOpaquePtr(); }
- void setToType(unsigned Idx, QualType T) {
- assert(Idx < 3 && "To type index is out of range");
- ToTypePtrs[Idx] = T.getAsOpaquePtr();
- }
- void setAllToTypes(QualType T) {
- ToTypePtrs[0] = T.getAsOpaquePtr();
- ToTypePtrs[1] = ToTypePtrs[0];
- ToTypePtrs[2] = ToTypePtrs[0];
- }
-
- QualType getFromType() const {
- return QualType::getFromOpaquePtr(FromTypePtr);
- }
- QualType getToType(unsigned Idx) const {
- assert(Idx < 3 && "To type index is out of range");
- return QualType::getFromOpaquePtr(ToTypePtrs[Idx]);
- }
-
- void setAsIdentityConversion();
-
- bool isIdentityConversion() const {
- return First == ICK_Identity && Second == ICK_Identity &&
- Third == ICK_Identity;
- }
-
- ImplicitConversionRank getRank() const;
- bool isPointerConversionToBool() const;
- bool isPointerConversionToVoidPointer(ASTContext& Context) const;
- void DebugPrint() const;
- };
-
- /// UserDefinedConversionSequence - Represents a user-defined
- /// conversion sequence (C++ 13.3.3.1.2).
- struct UserDefinedConversionSequence {
- /// Before - Represents the standard conversion that occurs before
- /// the actual user-defined conversion. (C++ 13.3.3.1.2p1):
- ///
- /// If the user-defined conversion is specified by a constructor
- /// (12.3.1), the initial standard conversion sequence converts
- /// the source type to the type required by the argument of the
- /// constructor. If the user-defined conversion is specified by
- /// a conversion function (12.3.2), the initial standard
- /// conversion sequence converts the source type to the implicit
- /// object parameter of the conversion function.
- StandardConversionSequence Before;
-
- /// EllipsisConversion - When this is true, it means user-defined
- /// conversion sequence starts with a ... (elipsis) conversion, instead of
- /// a standard conversion. In this case, 'Before' field must be ignored.
- // FIXME. I much rather put this as the first field. But there seems to be
- // a gcc code gen. bug which causes a crash in a test. Putting it here seems
- // to work around the crash.
- bool EllipsisConversion : 1;
-
- /// After - Represents the standard conversion that occurs after
- /// the actual user-defined conversion.
- StandardConversionSequence After;
-
- /// ConversionFunction - The function that will perform the
- /// user-defined conversion.
- FunctionDecl* ConversionFunction;
-
- void DebugPrint() const;
- };
-
- /// Represents an ambiguous user-defined conversion sequence.
- struct AmbiguousConversionSequence {
- typedef llvm::SmallVector<FunctionDecl*, 4> ConversionSet;
-
- void *FromTypePtr;
- void *ToTypePtr;
- char Buffer[sizeof(ConversionSet)];
-
- QualType getFromType() const {
- return QualType::getFromOpaquePtr(FromTypePtr);
- }
- QualType getToType() const {
- return QualType::getFromOpaquePtr(ToTypePtr);
- }
- void setFromType(QualType T) { FromTypePtr = T.getAsOpaquePtr(); }
- void setToType(QualType T) { ToTypePtr = T.getAsOpaquePtr(); }
-
- ConversionSet &conversions() {
- return *reinterpret_cast<ConversionSet*>(Buffer);
- }
-
- const ConversionSet &conversions() const {
- return *reinterpret_cast<const ConversionSet*>(Buffer);
- }
-
- void addConversion(FunctionDecl *D) {
- conversions().push_back(D);
- }
-
- typedef ConversionSet::iterator iterator;
- iterator begin() { return conversions().begin(); }
- iterator end() { return conversions().end(); }
-
- typedef ConversionSet::const_iterator const_iterator;
- const_iterator begin() const { return conversions().begin(); }
- const_iterator end() const { return conversions().end(); }
-
- void construct();
- void destruct();
- void copyFrom(const AmbiguousConversionSequence &);
- };
-
- /// BadConversionSequence - Records information about an invalid
- /// conversion sequence.
- struct BadConversionSequence {
- enum FailureKind {
- no_conversion,
- unrelated_class,
- suppressed_user,
- bad_qualifiers
- };
-
- // This can be null, e.g. for implicit object arguments.
- Expr *FromExpr;
-
- FailureKind Kind;
-
- private:
- // The type we're converting from (an opaque QualType).
- void *FromTy;
-
- // The type we're converting to (an opaque QualType).
- void *ToTy;
-
- public:
- void init(FailureKind K, Expr *From, QualType To) {
- init(K, From->getType(), To);
- FromExpr = From;
- }
- void init(FailureKind K, QualType From, QualType To) {
- Kind = K;
- FromExpr = 0;
- setFromType(From);
- setToType(To);
- }
-
- QualType getFromType() const { return QualType::getFromOpaquePtr(FromTy); }
- QualType getToType() const { return QualType::getFromOpaquePtr(ToTy); }
-
- void setFromExpr(Expr *E) {
- FromExpr = E;
- setFromType(E->getType());
- }
- void setFromType(QualType T) { FromTy = T.getAsOpaquePtr(); }
- void setToType(QualType T) { ToTy = T.getAsOpaquePtr(); }
- };
-
- /// ImplicitConversionSequence - Represents an implicit conversion
- /// sequence, which may be a standard conversion sequence
- /// (C++ 13.3.3.1.1), user-defined conversion sequence (C++ 13.3.3.1.2),
- /// or an ellipsis conversion sequence (C++ 13.3.3.1.3).
- struct ImplicitConversionSequence {
- /// Kind - The kind of implicit conversion sequence. BadConversion
- /// specifies that there is no conversion from the source type to
- /// the target type. AmbiguousConversion represents the unique
- /// ambiguous conversion (C++0x [over.best.ics]p10).
- enum Kind {
- StandardConversion = 0,
- UserDefinedConversion,
- AmbiguousConversion,
- EllipsisConversion,
- BadConversion
- };
-
- private:
- enum {
- Uninitialized = BadConversion + 1
- };
-
- /// ConversionKind - The kind of implicit conversion sequence.
- unsigned ConversionKind;
-
- void setKind(Kind K) {
- destruct();
- ConversionKind = K;
- }
-
- void destruct() {
- if (ConversionKind == AmbiguousConversion) Ambiguous.destruct();
- }
-
- public:
- union {
- /// When ConversionKind == StandardConversion, provides the
- /// details of the standard conversion sequence.
- StandardConversionSequence Standard;
-
- /// When ConversionKind == UserDefinedConversion, provides the
- /// details of the user-defined conversion sequence.
- UserDefinedConversionSequence UserDefined;
-
- /// When ConversionKind == AmbiguousConversion, provides the
- /// details of the ambiguous conversion.
- AmbiguousConversionSequence Ambiguous;
-
- /// When ConversionKind == BadConversion, provides the details
- /// of the bad conversion.
- BadConversionSequence Bad;
- };
-
- ImplicitConversionSequence() : ConversionKind(Uninitialized) {}
- ~ImplicitConversionSequence() {
- destruct();
- }
- ImplicitConversionSequence(const ImplicitConversionSequence &Other)
- : ConversionKind(Other.ConversionKind)
- {
- switch (ConversionKind) {
- case Uninitialized: break;
- case StandardConversion: Standard = Other.Standard; break;
- case UserDefinedConversion: UserDefined = Other.UserDefined; break;
- case AmbiguousConversion: Ambiguous.copyFrom(Other.Ambiguous); break;
- case EllipsisConversion: break;
- case BadConversion: Bad = Other.Bad; break;
- }
- }
-
- ImplicitConversionSequence &
- operator=(const ImplicitConversionSequence &Other) {
- destruct();
- new (this) ImplicitConversionSequence(Other);
- return *this;
- }
-
- Kind getKind() const {
- assert(isInitialized() && "querying uninitialized conversion");
- return Kind(ConversionKind);
- }
-
- /// \brief Return a ranking of the implicit conversion sequence
- /// kind, where smaller ranks represent better conversion
- /// sequences.
- ///
- /// In particular, this routine gives user-defined conversion
- /// sequences and ambiguous conversion sequences the same rank,
- /// per C++ [over.best.ics]p10.
- unsigned getKindRank() const {
- switch (getKind()) {
- case StandardConversion:
- return 0;
-
- case UserDefinedConversion:
- case AmbiguousConversion:
- return 1;
-
- case EllipsisConversion:
- return 2;
-
- case BadConversion:
- return 3;
- }
-
- return 3;
- }
-
- bool isBad() const { return getKind() == BadConversion; }
- bool isStandard() const { return getKind() == StandardConversion; }
- bool isEllipsis() const { return getKind() == EllipsisConversion; }
- bool isAmbiguous() const { return getKind() == AmbiguousConversion; }
- bool isUserDefined() const { return getKind() == UserDefinedConversion; }
-
- /// Determines whether this conversion sequence has been
- /// initialized. Most operations should never need to query
- /// uninitialized conversions and should assert as above.
- bool isInitialized() const { return ConversionKind != Uninitialized; }
-
- /// Sets this sequence as a bad conversion for an explicit argument.
- void setBad(BadConversionSequence::FailureKind Failure,
- Expr *FromExpr, QualType ToType) {
- setKind(BadConversion);
- Bad.init(Failure, FromExpr, ToType);
- }
-
- /// Sets this sequence as a bad conversion for an implicit argument.
- void setBad(BadConversionSequence::FailureKind Failure,
- QualType FromType, QualType ToType) {
- setKind(BadConversion);
- Bad.init(Failure, FromType, ToType);
- }
-
- void setStandard() { setKind(StandardConversion); }
- void setEllipsis() { setKind(EllipsisConversion); }
- void setUserDefined() { setKind(UserDefinedConversion); }
- void setAmbiguous() {
- if (ConversionKind == AmbiguousConversion) return;
- ConversionKind = AmbiguousConversion;
- Ambiguous.construct();
- }
-
- // The result of a comparison between implicit conversion
- // sequences. Use Sema::CompareImplicitConversionSequences to
- // actually perform the comparison.
- enum CompareKind {
- Better = -1,
- Indistinguishable = 0,
- Worse = 1
- };
-
- void DebugPrint() const;
- };
-
- enum OverloadFailureKind {
- ovl_fail_too_many_arguments,
- ovl_fail_too_few_arguments,
- ovl_fail_bad_conversion,
- ovl_fail_bad_deduction,
-
- /// This conversion candidate was not considered because it
- /// duplicates the work of a trivial or derived-to-base
- /// conversion.
- ovl_fail_trivial_conversion,
-
- /// This conversion candidate is not viable because its result
- /// type is not implicitly convertible to the desired type.
- ovl_fail_bad_final_conversion,
-
- /// This conversion function template specialization candidate is not
- /// viable because the final conversion was not an exact match.
- ovl_fail_final_conversion_not_exact
- };
-
- /// OverloadCandidate - A single candidate in an overload set (C++ 13.3).
- struct OverloadCandidate {
- /// Function - The actual function that this candidate
- /// represents. When NULL, this is a built-in candidate
- /// (C++ [over.oper]) or a surrogate for a conversion to a
- /// function pointer or reference (C++ [over.call.object]).
- FunctionDecl *Function;
-
- /// FoundDecl - The original declaration that was looked up /
- /// invented / otherwise found, together with its access.
- /// Might be a UsingShadowDecl or a FunctionTemplateDecl.
- DeclAccessPair FoundDecl;
-
- // BuiltinTypes - Provides the return and parameter types of a
- // built-in overload candidate. Only valid when Function is NULL.
- struct {
- QualType ResultTy;
- QualType ParamTypes[3];
- } BuiltinTypes;
-
- /// Surrogate - The conversion function for which this candidate
- /// is a surrogate, but only if IsSurrogate is true.
- CXXConversionDecl *Surrogate;
-
- /// Conversions - The conversion sequences used to convert the
- /// function arguments to the function parameters.
- llvm::SmallVector<ImplicitConversionSequence, 4> Conversions;
-
- /// Viable - True to indicate that this overload candidate is viable.
- bool Viable;
-
- /// 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;
-
- /// IgnoreObjectArgument - True to indicate that the first
- /// argument's conversion, which for this function represents the
- /// implicit object argument, should be ignored. This will be true
- /// when the candidate is a static member function (where the
- /// implicit object argument is just a placeholder) or a
- /// non-static member function when the call doesn't have an
- /// object argument.
- bool IgnoreObjectArgument;
-
- /// FailureKind - The reason why this candidate is not viable.
- /// Actually an OverloadFailureKind.
- unsigned char FailureKind;
-
- /// A structure used to record information about a failed
- /// template argument deduction.
- struct DeductionFailureInfo {
- // A Sema::TemplateDeductionResult.
- unsigned Result;
-
- /// \brief Opaque pointer containing additional data about
- /// this deduction failure.
- void *Data;
-
- /// \brief Retrieve the template parameter this deduction failure
- /// refers to, if any.
- TemplateParameter getTemplateParameter();
-
- /// \brief Retrieve the template argument list associated with this
- /// deduction failure, if any.
- TemplateArgumentList *getTemplateArgumentList();
-
- /// \brief Return the first template argument this deduction failure
- /// refers to, if any.
- const TemplateArgument *getFirstArg();
-
- /// \brief Return the second template argument this deduction failure
- /// refers to, if any.
- const TemplateArgument *getSecondArg();
-
- /// \brief Free any memory associated with this deduction failure.
- void Destroy();
- };
-
- union {
- DeductionFailureInfo DeductionFailure;
-
- /// FinalConversion - For a conversion function (where Function is
- /// a CXXConversionDecl), the standard conversion that occurs
- /// after the call to the overload candidate to convert the result
- /// of calling the conversion function to the required type.
- StandardConversionSequence FinalConversion;
- };
-
- /// hasAmbiguousConversion - Returns whether this overload
- /// candidate requires an ambiguous conversion or not.
- bool hasAmbiguousConversion() const {
- for (llvm::SmallVectorImpl<ImplicitConversionSequence>::const_iterator
- I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
- if (!I->isInitialized()) return false;
- if (I->isAmbiguous()) return true;
- }
- return false;
- }
- };
-
- /// OverloadCandidateSet - A set of overload candidates, used in C++
- /// overload resolution (C++ 13.3).
- class OverloadCandidateSet : public llvm::SmallVector<OverloadCandidate, 16> {
- typedef llvm::SmallVector<OverloadCandidate, 16> inherited;
- llvm::SmallPtrSet<Decl *, 16> Functions;
-
- SourceLocation Loc;
-
- OverloadCandidateSet(const OverloadCandidateSet &);
- OverloadCandidateSet &operator=(const OverloadCandidateSet &);
-
- public:
- OverloadCandidateSet(SourceLocation Loc) : Loc(Loc) {}
-
- SourceLocation getLocation() const { return Loc; }
-
- /// \brief Determine when this overload candidate will be new to the
- /// overload set.
- bool isNewCandidate(Decl *F) {
- return Functions.insert(F->getCanonicalDecl());
- }
-
- /// \brief Clear out all of the candidates.
- void clear();
-
- ~OverloadCandidateSet() { clear(); }
- };
-} // end namespace clang
-
-#endif // LLVM_CLANG_SEMA_OVERLOAD_H
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Thu Aug 12 15:07:10 2010
@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
-#include "SemaInit.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Initialization.h"
#include "clang/AST/APValue.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Aug 12 15:07:10 2010
@@ -9,8 +9,8 @@
// This file implements semantic analysis for C++ templates.
//===----------------------------------------------------------------------===/
-#include "Sema.h"
-#include "Lookup.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Lookup.h"
#include "TreeTransform.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Expr.h"
Removed: cfe/trunk/lib/Sema/SemaTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.h?rev=110944&view=auto
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.h (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.h (removed)
@@ -1,151 +0,0 @@
-//===------- SemaTemplate.h - C++ Templates ---------------------*- C++ -*-===/
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//===----------------------------------------------------------------------===/
-//
-// This file provides types used in the semantic analysis of C++ templates.
-//
-//===----------------------------------------------------------------------===/
-#ifndef LLVM_CLANG_SEMA_TEMPLATE_H
-#define LLVM_CLANG_SEMA_TEMPLATE_H
-
-#include "clang/AST/DeclTemplate.h"
-#include "llvm/ADT/SmallVector.h"
-#include <cassert>
-
-namespace clang {
- /// \brief Data structure that captures multiple levels of template argument
- /// lists for use in template instantiation.
- ///
- /// Multiple levels of template arguments occur when instantiating the
- /// definitions of member templates. For example:
- ///
- /// \code
- /// template<typename T>
- /// struct X {
- /// template<T Value>
- /// struct Y {
- /// void f();
- /// };
- /// };
- /// \endcode
- ///
- /// When instantiating X<int>::Y<17>::f, the multi-level template argument
- /// list will contain a template argument list (int) at depth 0 and a
- /// template argument list (17) at depth 1.
- class MultiLevelTemplateArgumentList {
- public:
- typedef std::pair<const TemplateArgument *, unsigned> ArgList;
-
- private:
- /// \brief The template argument lists, stored from the innermost template
- /// argument list (first) to the outermost template argument list (last).
- llvm::SmallVector<ArgList, 4> TemplateArgumentLists;
-
- public:
- /// \brief Construct an empty set of template argument lists.
- MultiLevelTemplateArgumentList() { }
-
- /// \brief Construct a single-level template argument list.
- explicit
- MultiLevelTemplateArgumentList(const TemplateArgumentList &TemplateArgs) {
- addOuterTemplateArguments(&TemplateArgs);
- }
-
- /// \brief Determine the number of levels in this template argument
- /// list.
- unsigned getNumLevels() const { return TemplateArgumentLists.size(); }
-
- /// \brief Retrieve the template argument at a given depth and index.
- const TemplateArgument &operator()(unsigned Depth, unsigned Index) const {
- assert(Depth < TemplateArgumentLists.size());
- assert(Index < TemplateArgumentLists[getNumLevels() - Depth - 1].second);
- return TemplateArgumentLists[getNumLevels() - Depth - 1].first[Index];
- }
-
- /// \brief Determine whether there is a non-NULL template argument at the
- /// given depth and index.
- ///
- /// There must exist a template argument list at the given depth.
- bool hasTemplateArgument(unsigned Depth, unsigned Index) const {
- assert(Depth < TemplateArgumentLists.size());
-
- if (Index >= TemplateArgumentLists[getNumLevels() - Depth - 1].second)
- return false;
-
- return !(*this)(Depth, Index).isNull();
- }
-
- /// \brief Add a new outermost level to the multi-level template argument
- /// list.
- void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs) {
- TemplateArgumentLists.push_back(
- ArgList(TemplateArgs->getFlatArgumentList(),
- TemplateArgs->flat_size()));
- }
-
- /// \brief Add a new outmost level to the multi-level template argument
- /// list.
- void addOuterTemplateArguments(const TemplateArgument *Args,
- unsigned NumArgs) {
- TemplateArgumentLists.push_back(ArgList(Args, NumArgs));
- }
-
- /// \brief Retrieve the innermost template argument list.
- const ArgList &getInnermost() const {
- return TemplateArgumentLists.front();
- }
- };
-
- /// \brief The context in which partial ordering of function templates occurs.
- enum TemplatePartialOrderingContext {
- /// \brief Partial ordering of function templates for a function call.
- TPOC_Call,
- /// \brief Partial ordering of function templates for a call to a
- /// conversion function.
- TPOC_Conversion,
- /// \brief Partial ordering of function templates in other contexts, e.g.,
- /// taking the address of a function template or matching a function
- /// template specialization to a function template.
- TPOC_Other
- };
-
- /// \brief Captures a template argument whose value has been deduced
- /// via c++ template argument deduction.
- class DeducedTemplateArgument : public TemplateArgument {
- /// \brief For a non-type template argument, whether the value was
- /// deduced from an array bound.
- bool DeducedFromArrayBound;
-
- public:
- DeducedTemplateArgument()
- : TemplateArgument(), DeducedFromArrayBound(false) { }
-
- DeducedTemplateArgument(const TemplateArgument &Arg,
- bool DeducedFromArrayBound = false)
- : TemplateArgument(Arg), DeducedFromArrayBound(DeducedFromArrayBound) { }
-
- /// \brief Construct an integral non-type template argument that
- /// has been deduced, possible from an array bound.
- DeducedTemplateArgument(const llvm::APSInt &Value,
- QualType ValueType,
- bool DeducedFromArrayBound)
- : TemplateArgument(Value, ValueType),
- DeducedFromArrayBound(DeducedFromArrayBound) { }
-
- /// \brief For a non-type template argument, determine whether the
- /// template argument was deduced from an array bound.
- bool wasDeducedFromArrayBound() const { return DeducedFromArrayBound; }
-
- /// \brief Specify whether the given non-type template argument
- /// was deduced from an array bound.
- void setDeducedFromArrayBound(bool Deduced) {
- DeducedFromArrayBound = Deduced;
- }
- };
-}
-
-#endif // LLVM_CLANG_SEMA_TEMPLATE_H
Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Thu Aug 12 15:07:10 2010
@@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===/
-#include "Sema.h"
+#include "clang/Sema/Sema.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/StmtVisitor.h"
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Thu Aug 12 15:07:10 2010
@@ -10,9 +10,9 @@
//
//===----------------------------------------------------------------------===/
-#include "Sema.h"
+#include "clang/Sema/Sema.h"
#include "TreeTransform.h"
-#include "Lookup.h"
+#include "clang/Sema/Lookup.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Expr.h"
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Thu Aug 12 15:07:10 2010
@@ -9,8 +9,8 @@
// This file implements C++ template instantiation for declarations.
//
//===----------------------------------------------------------------------===/
-#include "Sema.h"
-#include "Lookup.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Lookup.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclTemplate.h"
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Aug 12 15:07:10 2010
@@ -11,7 +11,7 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
+#include "clang/Sema/Sema.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/DeclObjC.h"
Modified: cfe/trunk/lib/Sema/TargetAttributesSema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TargetAttributesSema.cpp?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TargetAttributesSema.cpp (original)
+++ cfe/trunk/lib/Sema/TargetAttributesSema.cpp Thu Aug 12 15:07:10 2010
@@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
-#include "Sema.h"
+#include "clang/Sema/Sema.h"
#include "TargetAttributesSema.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/Triple.h"
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=110945&r1=110944&r2=110945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu Aug 12 15:07:10 2010
@@ -13,8 +13,8 @@
#ifndef LLVM_CLANG_SEMA_TREETRANSFORM_H
#define LLVM_CLANG_SEMA_TREETRANSFORM_H
-#include "Sema.h"
-#include "Lookup.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/Lookup.h"
#include "clang/Sema/SemaDiagnostic.h"
#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
More information about the cfe-commits
mailing list