From 53992adde3eda3ccf9da63bc7e45673f043de18f Mon Sep 17 00:00:00 2001 From: rdivacky Date: Thu, 27 May 2010 15:17:06 +0000 Subject: Update clang to r104832. --- lib/Basic/Diagnostic.cpp | 37 ++++++++++-- lib/Basic/IdentifierTable.cpp | 4 +- lib/Basic/SourceManager.cpp | 131 ++++++++++++++++++++++++------------------ lib/Basic/TargetInfo.cpp | 1 + lib/Basic/Targets.cpp | 5 +- lib/Basic/Version.cpp | 3 +- 6 files changed, 117 insertions(+), 64 deletions(-) (limited to 'lib/Basic') diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index 9e6f168..2fd985f 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -127,6 +127,35 @@ const char *Diagnostic::getWarningOptionForDiag(unsigned DiagID) { return 0; } +/// getWarningOptionForDiag - Return the category number that a specified +/// DiagID belongs to, or 0 if no category. +unsigned Diagnostic::getCategoryNumberForDiag(unsigned DiagID) { + if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID)) + return Info->Category; + return 0; +} + +/// getCategoryNameFromID - Given a category ID, return the name of the +/// category, an empty string if CategoryID is zero, or null if CategoryID is +/// invalid. +const char *Diagnostic::getCategoryNameFromID(unsigned CategoryID) { + // Second the table of options, sorted by name for fast binary lookup. + static const char *CategoryNameTable[] = { +#define GET_CATEGORY_TABLE +#define CATEGORY(X) X, +#include "clang/Basic/DiagnosticGroups.inc" +#undef GET_CATEGORY_TABLE + "<>" + }; + static const size_t CategoryNameTableSize = + sizeof(CategoryNameTable) / sizeof(CategoryNameTable[0])-1; + + if (CategoryID >= CategoryNameTableSize) return 0; + return CategoryNameTable[CategoryID]; +} + + + Diagnostic::SFINAEResponse Diagnostic::getDiagnosticSFINAEResponse(unsigned DiagID) { if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID)) { @@ -432,7 +461,7 @@ Diagnostic::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass) const { struct WarningOption { const char *Name; const short *Members; - const char *SubGroups; + const short *SubGroups; }; #define GET_DIAG_ARRAYS @@ -462,9 +491,9 @@ static void MapGroupMembers(const WarningOption *Group, diag::Mapping Mapping, } // Enable/disable all subgroups along with this one. - if (const char *SubGroups = Group->SubGroups) { - for (; *SubGroups != (char)-1; ++SubGroups) - MapGroupMembers(&OptionTable[(unsigned char)*SubGroups], Mapping, Diags); + if (const short *SubGroups = Group->SubGroups) { + for (; *SubGroups != (short)-1; ++SubGroups) + MapGroupMembers(&OptionTable[(short)*SubGroups], Mapping, Diags); } } diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp index ed0de8c..8993e67 100644 --- a/lib/Basic/IdentifierTable.cpp +++ b/lib/Basic/IdentifierTable.cpp @@ -70,7 +70,8 @@ namespace { KEYGNU = 16, KEYMS = 32, BOOLSUPPORT = 64, - KEYALTIVEC = 128 + KEYALTIVEC = 128, + KEYNOMS = 256 }; } @@ -94,6 +95,7 @@ static void AddKeyword(llvm::StringRef Keyword, else if (LangOpts.Microsoft && (Flags & KEYMS)) AddResult = 1; else if (LangOpts.Bool && (Flags & BOOLSUPPORT)) AddResult = 2; else if (LangOpts.AltiVec && (Flags & KEYALTIVEC)) AddResult = 2; + else if (!LangOpts.Microsoft && (Flags & KEYNOMS)) AddResult = 2; // Don't add this keyword if disabled in this language. if (AddResult == 0) return; diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 3ecab1d..e6d9785 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -1154,6 +1154,27 @@ SourceLocation SourceManager::getLocation(const FileEntry *SourceFile, return getLocForStartOfFile(FirstFID).getFileLocWithOffset(FilePos + Col - 1); } +/// Given a decomposed source location, move it up the include/instantiation +/// stack to the parent source location. If this is possible, return the +/// decomposed version of the parent in Loc and return false. If Loc is the +/// top-level entry, return true and don't modify it. +static bool MoveUpIncludeHierarchy(std::pair &Loc, + const SourceManager &SM) { + SourceLocation UpperLoc; + const SrcMgr::SLocEntry &Entry = SM.getSLocEntry(Loc.first); + if (Entry.isInstantiation()) + UpperLoc = Entry.getInstantiation().getInstantiationLocStart(); + else + UpperLoc = Entry.getFile().getIncludeLoc(); + + if (UpperLoc.isInvalid()) + return true; // We reached the top. + + Loc = SM.getDecomposedLoc(UpperLoc); + return false; +} + + /// \brief Determines the order of 2 source locations in the translation unit. /// /// \returns true if LHS source location comes before RHS, false otherwise. @@ -1172,78 +1193,74 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS, // If we are comparing a source location with multiple locations in the same // file, we get a big win by caching the result. + if (IsBeforeInTUCache.isCacheValid(LOffs.first, ROffs.first)) + return IsBeforeInTUCache.getCachedResult(LOffs.second, ROffs.second); - if (LastLFIDForBeforeTUCheck == LOffs.first && - LastRFIDForBeforeTUCheck == ROffs.first) - return LastResForBeforeTUCheck; - - LastLFIDForBeforeTUCheck = LOffs.first; - LastRFIDForBeforeTUCheck = ROffs.first; + // Okay, we missed in the cache, start updating the cache for this query. + IsBeforeInTUCache.setQueryFIDs(LOffs.first, ROffs.first); // "Traverse" the include/instantiation stacks of both locations and try to - // find a common "ancestor". + // find a common "ancestor". FileIDs build a tree-like structure that + // reflects the #include hierarchy, and this algorithm needs to find the + // nearest common ancestor between the two locations. For example, if you + // have a.c that includes b.h and c.h, and are comparing a location in b.h to + // a location in c.h, we need to find that their nearest common ancestor is + // a.c, and compare the locations of the two #includes to find their relative + // ordering. // - // First we traverse the stack of the right location and check each level - // against the level of the left location, while collecting all levels in a - // "stack map". - - std::map ROffsMap; - ROffsMap[ROffs.first] = ROffs.second; - - while (1) { - SourceLocation UpperLoc; - const SrcMgr::SLocEntry &Entry = getSLocEntry(ROffs.first); - if (Entry.isInstantiation()) - UpperLoc = Entry.getInstantiation().getInstantiationLocStart(); - else - UpperLoc = Entry.getFile().getIncludeLoc(); - - if (UpperLoc.isInvalid()) - break; // We reached the top. - - ROffs = getDecomposedLoc(UpperLoc); - - if (LOffs.first == ROffs.first) - return LastResForBeforeTUCheck = LOffs.second < ROffs.second; - - ROffsMap[ROffs.first] = ROffs.second; - } - - // We didn't find a common ancestor. Now traverse the stack of the left - // location, checking against the stack map of the right location. - - while (1) { - SourceLocation UpperLoc; - const SrcMgr::SLocEntry &Entry = getSLocEntry(LOffs.first); - if (Entry.isInstantiation()) - UpperLoc = Entry.getInstantiation().getInstantiationLocStart(); - else - UpperLoc = Entry.getFile().getIncludeLoc(); - - if (UpperLoc.isInvalid()) - break; // We reached the top. - - LOffs = getDecomposedLoc(UpperLoc); + // SourceManager assigns FileIDs in order of parsing. This means that an + // includee always has a larger FileID than an includer. While you might + // think that we could just compare the FileID's here, that doesn't work to + // compare a point at the end of a.c with a point within c.h. Though c.h has + // a larger FileID, we have to compare the include point of c.h to the + // location in a.c. + // + // Despite not being able to directly compare FileID's, we can tell that a + // larger FileID is necessarily more deeply nested than a lower one and use + // this information to walk up the tree to the nearest common ancestor. + do { + // If LOffs is larger than ROffs, then LOffs must be more deeply nested than + // ROffs, walk up the #include chain. + if (LOffs.first.ID > ROffs.first.ID) { + if (MoveUpIncludeHierarchy(LOffs, *this)) + break; // We reached the top. + + } else { + // Otherwise, ROffs is larger than LOffs, so ROffs must be more deeply + // nested than LOffs, walk up the #include chain. + if (MoveUpIncludeHierarchy(ROffs, *this)) + break; // We reached the top. + } + } while (LOffs.first != ROffs.first); - std::map::iterator I = ROffsMap.find(LOffs.first); - if (I != ROffsMap.end()) - return LastResForBeforeTUCheck = LOffs.second < I->second; + // If we exited because we found a nearest common ancestor, compare the + // locations within the common file and cache them. + if (LOffs.first == ROffs.first) { + IsBeforeInTUCache.setCommonLoc(LOffs.first, LOffs.second, ROffs.second); + return IsBeforeInTUCache.getCachedResult(LOffs.second, ROffs.second); } // There is no common ancestor, most probably because one location is in the - // predefines buffer. - // + // predefines buffer or a PCH file. // FIXME: We should rearrange the external interface so this simply never // happens; it can't conceptually happen. Also see PR5662. + IsBeforeInTUCache.setQueryFIDs(FileID(), FileID()); // Don't try caching. + // Zip both entries up to the top level record. + while (!MoveUpIncludeHierarchy(LOffs, *this)) /*empty*/; + while (!MoveUpIncludeHierarchy(ROffs, *this)) /*empty*/; + // If exactly one location is a memory buffer, assume it preceeds the other. - bool LIsMB = !getSLocEntry(LOffs.first).getFile().getContentCache()->Entry; - bool RIsMB = !getSLocEntry(ROffs.first).getFile().getContentCache()->Entry; + + // Strip off macro instantation locations, going up to the top-level File + // SLocEntry. + bool LIsMB = getFileEntryForID(LOffs.first) == 0; + bool RIsMB = getFileEntryForID(ROffs.first) == 0; if (LIsMB != RIsMB) - return LastResForBeforeTUCheck = LIsMB; + return LIsMB; // Otherwise, just assume FileIDs were created in order. - return LastResForBeforeTUCheck = (LOffs.first < ROffs.first); + return LOffs.first < ROffs.first; } /// PrintStats - Print statistics to stderr. diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp index 4c0c59a..6692e64 100644 --- a/lib/Basic/TargetInfo.cpp +++ b/lib/Basic/TargetInfo.cpp @@ -52,6 +52,7 @@ TargetInfo::TargetInfo(const std::string &T) : Triple(T) { DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" "i64:64:64-f32:32:32-f64:64:64-n32"; UserLabelPrefix = "_"; + HasAlignMac68kSupport = false; } // Out of line virtual dtor for TargetInfo. diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 3d5048c..92fd417 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -1138,6 +1138,7 @@ public: DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" "i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-" "a0:0:64-f80:128:128-n8:16:32"; + HasAlignMac68kSupport = true; } }; @@ -1669,7 +1670,9 @@ protected: public: DarwinARMTargetInfo(const std::string& triple) - : DarwinTargetInfo(triple) {} + : DarwinTargetInfo(triple) { + HasAlignMac68kSupport = true; + } }; } // end anonymous namespace. diff --git a/lib/Basic/Version.cpp b/lib/Basic/Version.cpp index dc87d14..e0c2336 100644 --- a/lib/Basic/Version.cpp +++ b/lib/Basic/Version.cpp @@ -28,7 +28,8 @@ llvm::StringRef getClangRepositoryPath() { if (End) URLEnd = End; - End = strstr(URL, "/clang/tools/clang"); + // Strip off version from a build from an integration branch. + End = strstr(URL, "/src/tools/clang"); if (End) URLEnd = End; -- cgit v1.1