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,14 @@ #include "clang/AST/TemplateName.h" #include "clang/AST/Type.h" #include "clang/AST/TypeLoc.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 +81,7 @@ do { \ if (!getDerived().CALL_EXPR) \ return false; \ - } while (0) + } while (false) /// \brief A class that does preorder depth-first traversal on the /// entire Clang AST and visits each node. @@ -320,7 +331,7 @@ do { \ if (!TRAVERSE_STMT_BASE(Stmt, Stmt, S, Queue)) \ return false; \ - } while (0) + } while (false) public: // Declare Traverse*() for all concrete Stmt classes. @@ -2000,6 +2011,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()); @@ -2009,10 +2021,12 @@ return true; } }) + 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, {}) @@ -2254,14 +2268,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, {}) @@ -2270,6 +2288,7 @@ DEF_TRAVERSE_STMT(ExprWithCleanups, {}) DEF_TRAVERSE_STMT(CXXNullPtrLiteralExpr, {}) DEF_TRAVERSE_STMT(CXXStdInitializerListExpr, {}) + DEF_TRAVERSE_STMT(CXXPseudoDestructorExpr, { TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc())); if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo()) @@ -2277,6 +2296,7 @@ if (TypeSourceInfo *DestroyedTypeInfo = S->getDestroyedTypeInfo()) TRY_TO(TraverseTypeLoc(DestroyedTypeInfo->getTypeLoc())); }) + DEF_TRAVERSE_STMT(CXXThisExpr, {}) DEF_TRAVERSE_STMT(CXXThrowExpr, {}) DEF_TRAVERSE_STMT(UserDefinedLiteral, {}) @@ -2287,30 +2307,37 @@ 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(ParenExpr, {}) DEF_TRAVERSE_STMT(ParenListExpr, {}) DEF_TRAVERSE_STMT(PredefinedExpr, {}) DEF_TRAVERSE_STMT(ShuffleVectorExpr, {}) DEF_TRAVERSE_STMT(ConvertVectorExpr, {}) DEF_TRAVERSE_STMT(StmtExpr, {}) + DEF_TRAVERSE_STMT(UnresolvedLookupExpr, { TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc())); if (S->hasExplicitTemplateArgs()) { @@ -2364,12 +2391,14 @@ return true; } }) + DEF_TRAVERSE_STMT(CoreturnStmt, { if (!getDerived().shouldVisitImplicitCode()) { TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand()); return true; } }) + DEF_TRAVERSE_STMT(CoawaitExpr, { 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,14 +18,21 @@ #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; @@ -38,7 +45,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 +91,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 +143,7 @@ HasMacro = Val; if (Val) { - NeedsHandleIdentifier = 1; + NeedsHandleIdentifier = true; HadMacro = true; } else { RecomputeNeedsHandleIdentifier(); @@ -229,7 +235,7 @@ void setIsExtensionToken(bool Val) { IsExtension = Val; if (Val) - NeedsHandleIdentifier = 1; + NeedsHandleIdentifier = true; else RecomputeNeedsHandleIdentifier(); } @@ -243,7 +249,7 @@ void setIsFutureCompatKeyword(bool Val) { IsFutureCompatKeyword = Val; if (Val) - NeedsHandleIdentifier = 1; + NeedsHandleIdentifier = true; else RecomputeNeedsHandleIdentifier(); } @@ -253,7 +259,7 @@ void setIsPoisoned(bool Value = true) { IsPoisoned = Value; if (Value) - NeedsHandleIdentifier = 1; + NeedsHandleIdentifier = true; else RecomputeNeedsHandleIdentifier(); } @@ -266,7 +272,7 @@ void setIsCPlusPlusOperatorKeyword(bool Val = true) { IsCPPOperatorKeyword = Val; if (Val) - NeedsHandleIdentifier = 1; + NeedsHandleIdentifier = true; else RecomputeNeedsHandleIdentifier(); } @@ -371,6 +377,7 @@ class PoisonIdentifierRAIIObject { IdentifierInfo *const II; const bool OldValue; + public: PoisonIdentifierRAIIObject(IdentifierInfo *II, bool NewValue) : II(II), OldValue(II ? II->isPoisoned() : false) { @@ -823,7 +830,7 @@ unsigned ExtraKindOrNumArgs; }; -} // end namespace clang +} // end namespace clang namespace llvm { /// Define DenseMapInfo so that Selectors can be used as keys in DenseMap and @@ -833,6 +840,7 @@ static inline clang::Selector getEmptyKey() { return clang::Selector::getEmptyMarker(); } + static inline clang::Selector getTombstoneKey() { return clang::Selector::getTombstoneMarker(); } @@ -855,9 +863,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 +879,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 +893,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: lib/Basic/FileManager.cpp =================================================================== --- lib/Basic/FileManager.cpp +++ lib/Basic/FileManager.cpp @@ -20,16 +20,19 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemStatCache.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Config/llvm-config.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include #include -#include #include -#include +#include using namespace clang; @@ -494,7 +497,6 @@ UniqueRealFiles.erase(Entry->getUniqueID()); } - void FileManager::GetUniqueIDMapping( SmallVectorImpl &UIDToFiles) const { UIDToFiles.clear();