Index: include/clang/AST/RecursiveASTVisitor.h =================================================================== --- include/clang/AST/RecursiveASTVisitor.h +++ include/clang/AST/RecursiveASTVisitor.h @@ -11,13 +11,14 @@ // traverses the entire AST. // //===----------------------------------------------------------------------===// + #ifndef LLVM_CLANG_AST_RECURSIVEASTVISITOR_H #define LLVM_CLANG_AST_RECURSIVEASTVISITOR_H -#include - #include "clang/AST/Attr.h" #include "clang/AST/Decl.h" +#include "clang/AST/DeclarationName.h" +#include "clang/AST/DeclBase.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclFriend.h" #include "clang/AST/DeclObjC.h" @@ -27,7 +28,9 @@ #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" #include "clang/AST/ExprOpenMP.h" +#include "clang/AST/LambdaCapture.h" #include "clang/AST/NestedNameSpecifier.h" +#include "clang/AST/OpenMPClause.h" #include "clang/AST/Stmt.h" #include "clang/AST/StmtCXX.h" #include "clang/AST/StmtObjC.h" @@ -36,6 +39,15 @@ #include "clang/AST/TemplateName.h" #include "clang/AST/Type.h" #include "clang/AST/TypeLoc.h" +#include "clang/Basic/LLVM.h" +#include "clang/Basic/OpenMPKinds.h" +#include "clang/Basic/Specifiers.h" +#include "llvm/ADT/PointerIntPair.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Casting.h" +#include +#include +#include // The following three macros are used for meta programming. The code // using them is responsible for defining macro OPERATOR(). @@ -70,7 +82,7 @@ do { \ if (!getDerived().CALL_EXPR) \ return false; \ - } while (0) + } while (false) /// \brief A class that does preordor or postorder /// depth-first traversal on the entire Clang AST and visits each node. @@ -329,7 +341,7 @@ do { \ if (!TRAVERSE_STMT_BASE(Stmt, Stmt, S, Queue)) \ return false; \ - } while (0) + } while (false) public: // Declare Traverse*() for all concrete Stmt classes. @@ -567,7 +579,6 @@ #undef DISPATCH_STMT - template bool RecursiveASTVisitor::PostVisitStmt(Stmt *S) { switch (S->getStmtClass()) { @@ -756,7 +767,6 @@ case DeclarationName::CXXConversionFunctionName: if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo()) TRY_TO(TraverseTypeLoc(TSInfo->getTypeLoc())); - break; case DeclarationName::Identifier: @@ -2058,6 +2068,7 @@ DEF_TRAVERSE_STMT(ObjCAtTryStmt, {}) DEF_TRAVERSE_STMT(ObjCForCollectionStmt, {}) DEF_TRAVERSE_STMT(ObjCAutoreleasePoolStmt, {}) + DEF_TRAVERSE_STMT(CXXForRangeStmt, { if (!getDerived().shouldVisitImplicitCode()) { TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLoopVarStmt()); @@ -2067,10 +2078,12 @@ ShouldVisitChildren = false; } }) + DEF_TRAVERSE_STMT(MSDependentExistsStmt, { TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc())); TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo())); }) + DEF_TRAVERSE_STMT(ReturnStmt, {}) DEF_TRAVERSE_STMT(SwitchStmt, {}) DEF_TRAVERSE_STMT(WhileStmt, {}) @@ -2318,14 +2331,18 @@ DEF_TRAVERSE_STMT(AddrLabelExpr, {}) DEF_TRAVERSE_STMT(ArraySubscriptExpr, {}) DEF_TRAVERSE_STMT(OMPArraySectionExpr, {}) + DEF_TRAVERSE_STMT(BlockExpr, { TRY_TO(TraverseDecl(S->getBlockDecl())); return true; // no child statements to loop through. }) + DEF_TRAVERSE_STMT(ChooseExpr, {}) + DEF_TRAVERSE_STMT(CompoundLiteralExpr, { TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc())); }) + DEF_TRAVERSE_STMT(CXXBindTemporaryExpr, {}) DEF_TRAVERSE_STMT(CXXBoolLiteralExpr, {}) DEF_TRAVERSE_STMT(CXXDefaultArgExpr, {}) @@ -2335,6 +2352,7 @@ DEF_TRAVERSE_STMT(CXXInheritedCtorInitExpr, {}) DEF_TRAVERSE_STMT(CXXNullPtrLiteralExpr, {}) DEF_TRAVERSE_STMT(CXXStdInitializerListExpr, {}) + DEF_TRAVERSE_STMT(CXXPseudoDestructorExpr, { TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc())); if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo()) @@ -2342,6 +2360,7 @@ if (TypeSourceInfo *DestroyedTypeInfo = S->getDestroyedTypeInfo()) TRY_TO(TraverseTypeLoc(DestroyedTypeInfo->getTypeLoc())); }) + DEF_TRAVERSE_STMT(CXXThisExpr, {}) DEF_TRAVERSE_STMT(CXXThrowExpr, {}) DEF_TRAVERSE_STMT(UserDefinedLiteral, {}) @@ -2352,24 +2371,30 @@ DEF_TRAVERSE_STMT(ImplicitValueInitExpr, {}) DEF_TRAVERSE_STMT(NoInitExpr, {}) DEF_TRAVERSE_STMT(ObjCBoolLiteralExpr, {}) + DEF_TRAVERSE_STMT(ObjCEncodeExpr, { if (TypeSourceInfo *TInfo = S->getEncodedTypeSourceInfo()) TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc())); }) + DEF_TRAVERSE_STMT(ObjCIsaExpr, {}) DEF_TRAVERSE_STMT(ObjCIvarRefExpr, {}) + DEF_TRAVERSE_STMT(ObjCMessageExpr, { if (TypeSourceInfo *TInfo = S->getClassReceiverTypeInfo()) TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc())); }) + DEF_TRAVERSE_STMT(ObjCPropertyRefExpr, {}) DEF_TRAVERSE_STMT(ObjCSubscriptRefExpr, {}) DEF_TRAVERSE_STMT(ObjCProtocolExpr, {}) DEF_TRAVERSE_STMT(ObjCSelectorExpr, {}) DEF_TRAVERSE_STMT(ObjCIndirectCopyRestoreExpr, {}) + DEF_TRAVERSE_STMT(ObjCBridgedCastExpr, { TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc())); }) + DEF_TRAVERSE_STMT(ObjCAvailabilityCheckExpr, {}) DEF_TRAVERSE_STMT(ParenExpr, {}) DEF_TRAVERSE_STMT(ParenListExpr, {}) @@ -2377,6 +2402,7 @@ DEF_TRAVERSE_STMT(ShuffleVectorExpr, {}) DEF_TRAVERSE_STMT(ConvertVectorExpr, {}) DEF_TRAVERSE_STMT(StmtExpr, {}) + DEF_TRAVERSE_STMT(UnresolvedLookupExpr, { TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc())); if (S->hasExplicitTemplateArgs()) { @@ -2430,18 +2456,21 @@ ShouldVisitChildren = false; } }) + DEF_TRAVERSE_STMT(CoreturnStmt, { if (!getDerived().shouldVisitImplicitCode()) { TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand()); ShouldVisitChildren = false; } }) + DEF_TRAVERSE_STMT(CoawaitExpr, { if (!getDerived().shouldVisitImplicitCode()) { TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand()); ShouldVisitChildren = false; } }) + DEF_TRAVERSE_STMT(CoyieldExpr, { if (!getDerived().shouldVisitImplicitCode()) { TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand()); Index: include/clang/Basic/IdentifierTable.h =================================================================== --- include/clang/Basic/IdentifierTable.h +++ include/clang/Basic/IdentifierTable.h @@ -18,16 +18,26 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/TokenKinds.h" +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Allocator.h" #include +#include +#include +#include +#include #include +#include namespace llvm { + template struct DenseMapInfo; -} +} // end namespace llvm + namespace clang { + class LangOptions; class IdentifierInfo; class IdentifierTable; @@ -38,7 +48,6 @@ /// \brief A simple pair of identifier info and location. typedef std::pair IdentifierLocPair; - /// One of these records is kept for each identifier that /// is lexed. This contains information about whether the token was \#define'd, /// is a language keyword, or if it is a front-end token of some sort (e.g. a @@ -85,13 +94,13 @@ public: IdentifierInfo(); - /// \brief Return true if this is the identifier for the specified string. /// /// This is intended to be used for string literals only: II->isStr("foo"). template bool isStr(const char (&Str)[StrLen]) const { - return getLength() == StrLen-1 && !memcmp(getNameStart(), Str, StrLen-1); + return getLength() == StrLen-1 && + memcmp(getNameStart(), Str, StrLen-1) == 0; } /// \brief Return the beginning of the actual null-terminated string for this @@ -137,7 +146,7 @@ HasMacro = Val; if (Val) { - NeedsHandleIdentifier = 1; + NeedsHandleIdentifier = true; HadMacro = true; } else { RecomputeNeedsHandleIdentifier(); @@ -229,7 +238,7 @@ void setIsExtensionToken(bool Val) { IsExtension = Val; if (Val) - NeedsHandleIdentifier = 1; + NeedsHandleIdentifier = true; else RecomputeNeedsHandleIdentifier(); } @@ -243,7 +252,7 @@ void setIsFutureCompatKeyword(bool Val) { IsFutureCompatKeyword = Val; if (Val) - NeedsHandleIdentifier = 1; + NeedsHandleIdentifier = true; else RecomputeNeedsHandleIdentifier(); } @@ -253,7 +262,7 @@ void setIsPoisoned(bool Value = true) { IsPoisoned = Value; if (Value) - NeedsHandleIdentifier = 1; + NeedsHandleIdentifier = true; else RecomputeNeedsHandleIdentifier(); } @@ -266,7 +275,7 @@ void setIsCPlusPlusOperatorKeyword(bool Val = true) { IsCPPOperatorKeyword = Val; if (Val) - NeedsHandleIdentifier = 1; + NeedsHandleIdentifier = true; else RecomputeNeedsHandleIdentifier(); } @@ -371,6 +380,7 @@ class PoisonIdentifierRAIIObject { IdentifierInfo *const II; const bool OldValue; + public: PoisonIdentifierRAIIObject(IdentifierInfo *II, bool NewValue) : II(II), OldValue(II ? II->isPoisoned() : false) { @@ -537,7 +547,7 @@ iterator begin() const { return HashTable.begin(); } iterator end() const { return HashTable.end(); } - unsigned size() const { return HashTable.size(); } + unsigned size() const { return HashTable.size(); } /// \brief Print some statistics to stderr that indicate how well the /// hashing is doing. @@ -654,6 +664,7 @@ return reinterpret_cast(InfoPtr & ~ArgFlags); return nullptr; } + MultiKeywordSelector *getMultiKeywordSelector() const { return reinterpret_cast(InfoPtr & ~ArgFlags); } @@ -682,6 +693,7 @@ bool operator!=(Selector RHS) const { return InfoPtr != RHS.InfoPtr; } + void *getAsOpaquePtr() const { return reinterpret_cast(InfoPtr); } @@ -693,12 +705,13 @@ bool isKeywordSelector() const { return getIdentifierInfoFlag() != ZeroArg; } + bool isUnarySelector() const { return getIdentifierInfoFlag() == ZeroArg; } + unsigned getNumArgs() const; - /// \brief Retrieve the identifier at a given position in the selector. /// /// Note that the identifier pointer returned may be NULL. Clients that only @@ -743,6 +756,7 @@ static Selector getEmptyMarker() { return Selector(uintptr_t(-1)); } + static Selector getTombstoneMarker() { return Selector(uintptr_t(-2)); } @@ -756,6 +770,7 @@ void *Impl; // Actually a SelectorTableImpl SelectorTable(const SelectorTable &) = delete; void operator=(const SelectorTable &) = delete; + public: SelectorTable(); ~SelectorTable(); @@ -826,6 +841,7 @@ } // end namespace clang namespace llvm { + /// Define DenseMapInfo so that Selectors can be used as keys in DenseMap and /// DenseSets. template <> @@ -833,6 +849,7 @@ static inline clang::Selector getEmptyKey() { return clang::Selector::getEmptyMarker(); } + static inline clang::Selector getTombstoneKey() { return clang::Selector::getTombstoneMarker(); } @@ -855,9 +872,11 @@ static inline const void *getAsVoidPointer(clang::Selector P) { return P.getAsOpaquePtr(); } + static inline clang::Selector getFromVoidPointer(const void *P) { return clang::Selector(reinterpret_cast(P)); } + enum { NumLowBitsAvailable = 0 }; }; @@ -869,9 +888,11 @@ static inline void *getAsVoidPointer(clang::IdentifierInfo* P) { return P; } + static inline clang::IdentifierInfo *getFromVoidPointer(void *P) { return static_cast(P); } + enum { NumLowBitsAvailable = 1 }; }; @@ -881,11 +902,14 @@ static inline const void *getAsVoidPointer(const clang::IdentifierInfo* P) { return P; } + static inline const clang::IdentifierInfo *getFromVoidPointer(const void *P) { return static_cast(P); } + enum { NumLowBitsAvailable = 1 }; }; -} // end namespace llvm -#endif +} // end namespace llvm + +#endif // LLVM_CLANG_BASIC_IDENTIFIERTABLE_H Index: include/clang/Frontend/ASTUnit.h =================================================================== --- include/clang/Frontend/ASTUnit.h +++ include/clang/Frontend/ASTUnit.h @@ -16,8 +16,11 @@ #include "clang-c/Index.h" #include "clang/AST/ASTContext.h" +#include "clang/Basic/Diagnostic.h" #include "clang/Basic/FileSystemOptions.h" #include "clang/Basic/LangOptions.h" +#include "clang/Basic/Module.h" +#include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetOptions.h" #include "clang/Lex/HeaderSearchOptions.h" @@ -25,11 +28,20 @@ #include "clang/Lex/PreprocessingRecord.h" #include "clang/Sema/CodeCompleteConsumer.h" #include "clang/Serialization/ASTBitCodes.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/MD5.h" +#include #include +#include +#include #include #include #include @@ -37,10 +49,13 @@ #include namespace llvm { + class MemoryBuffer; -} +} // end namespace llvm + namespace clang { + class Sema; class ASTContext; class ASTReader; @@ -743,7 +758,6 @@ unsigned PrecompilePreambleAfterNParses); public: - /// \brief Create an ASTUnit from a source file, via a CompilerInvocation /// object, by invoking the optionally provided ASTFrontendAction. /// @@ -908,12 +922,16 @@ void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility, SourceLocation ImportLoc) override {} - GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override - { return nullptr; } - bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override - { return 0; } + GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override { + return nullptr; + } + + bool lookupMissingImports(StringRef Name, + SourceLocation TriggerLoc) override { + return false; + } }; -} // namespace clang +} // end namespace clang -#endif +#endif // LLVM_CLANG_FRONTEND_ASTUNIT_H Index: include/clang/Lex/PreprocessorOptions.h =================================================================== --- include/clang/Lex/PreprocessorOptions.h +++ include/clang/Lex/PreprocessorOptions.h @@ -7,28 +7,25 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_LEX_PREPROCESSOROPTIONS_H_ -#define LLVM_CLANG_LEX_PREPROCESSOROPTIONS_H_ +#ifndef LLVM_CLANG_LEX_PREPROCESSOROPTIONS_H +#define LLVM_CLANG_LEX_PREPROCESSOROPTIONS_H -#include "clang/Basic/SourceLocation.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" -#include #include #include #include #include namespace llvm { + class MemoryBuffer; -} +} // end namespace llvm + namespace clang { -class Preprocessor; -class LangOptions; - /// \brief Enumerate the kinds of standard library that enum ObjCXXARCStandardLibraryKind { ARCXX_nolib, @@ -175,10 +172,10 @@ TokenCache.clear(); RetainRemappedFileBuffers = true; PrecompiledPreambleBytes.first = 0; - PrecompiledPreambleBytes.second = 0; + PrecompiledPreambleBytes.second = false; } }; } // end namespace clang -#endif +#endif // LLVM_CLANG_LEX_PREPROCESSOROPTIONS_H Index: include/clang/Sema/CodeCompleteConsumer.h =================================================================== --- include/clang/Sema/CodeCompleteConsumer.h +++ include/clang/Sema/CodeCompleteConsumer.h @@ -10,20 +10,27 @@ // This file defines the CodeCompleteConsumer class. // //===----------------------------------------------------------------------===// + #ifndef LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H #define LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H #include "clang-c/Index.h" #include "clang/AST/CanonicalType.h" +#include "clang/AST/DeclarationName.h" #include "clang/AST/DeclBase.h" #include "clang/AST/Type.h" #include "clang/Sema/CodeCompleteOptions.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/None.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Twine.h" #include "llvm/Support/Allocator.h" +#include +#include #include -#include namespace clang { @@ -313,7 +320,6 @@ bool wantConstructorResults() const; }; - /// \brief A "string" used to describe how code completion can /// be performed for an entity. /// @@ -509,7 +515,6 @@ : public CodeCompletionAllocator, public RefCountedBase { - }; class CodeCompletionTUInfo { @@ -535,11 +540,13 @@ } // end namespace clang namespace llvm { + template <> struct isPodLike { static const bool value = true; }; -} +} // end namespace llvm + namespace clang { /// \brief A builder class used to construct new code-completion strings. @@ -707,7 +714,7 @@ : Declaration(nullptr), Keyword(Keyword), Priority(Priority), StartParameter(0), Kind(RK_Keyword), CursorKind(CXCursor_NotImplemented), Availability(CXAvailability_Available), Hidden(false), - QualifierIsInformative(0), StartsNestedNameSpecifier(false), + QualifierIsInformative(false), StartsNestedNameSpecifier(false), AllParametersAreInformative(false), DeclaringEntity(false), Qualifier(nullptr) {} @@ -717,7 +724,7 @@ : Declaration(nullptr), Macro(Macro), Priority(Priority), StartParameter(0), Kind(RK_Macro), CursorKind(CXCursor_MacroDefinition), Availability(CXAvailability_Available), Hidden(false), - QualifierIsInformative(0), StartsNestedNameSpecifier(false), + QualifierIsInformative(false), StartsNestedNameSpecifier(false), AllParametersAreInformative(false), DeclaringEntity(false), Qualifier(nullptr) {} @@ -729,7 +736,7 @@ const NamedDecl *D = nullptr) : Declaration(D), Pattern(Pattern), Priority(Priority), StartParameter(0), Kind(RK_Pattern), CursorKind(CursorKind), Availability(Availability), - Hidden(false), QualifierIsInformative(0), + Hidden(false), QualifierIsInformative(false), StartsNestedNameSpecifier(false), AllParametersAreInformative(false), DeclaringEntity(false), Qualifier(nullptr) { @@ -799,9 +806,8 @@ return !(X < Y); } - raw_ostream &operator<<(raw_ostream &OS, - const CodeCompletionString &CCS); + const CodeCompletionString &CCS); /// \brief Abstract interface for a consumer of code-completion /// information. Index: include/clang/Sema/Scope.h =================================================================== --- include/clang/Sema/Scope.h +++ include/clang/Sema/Scope.h @@ -16,15 +16,17 @@ #include "clang/AST/Decl.h" #include "clang/Basic/Diagnostic.h" +#include "llvm/ADT/iterator_range.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" +#include namespace llvm { class raw_ostream; -} +} // end namespace llvm namespace clang { @@ -125,6 +127,7 @@ /// We are currently in the filter expression of an SEH except block. SEHFilterScope = 0x200000, }; + private: /// The parent scope for this scope. This is null for the translation-unit /// scope. @@ -233,7 +236,6 @@ Scope *getContinueParent() { return ContinueParent; } - const Scope *getContinueParent() const { return const_cast(this)->getContinueParent(); } @@ -358,7 +360,6 @@ } return false; } - /// isTemplateParamScope - Return true if this scope is a C++ /// template parameter scope. @@ -463,7 +464,7 @@ } void setNoNRVO() { - NRVO.setInt(1); + NRVO.setInt(true); NRVO.setPointer(nullptr); } @@ -482,6 +483,6 @@ void dump() const; }; -} // end namespace clang +} // end namespace clang -#endif +#endif // LLVM_CLANG_SEMA_SCOPE_H