diff options
author | Roman Divacky <rdivacky@FreeBSD.org> | 2009-10-23 14:22:18 +0000 |
---|---|---|
committer | Roman Divacky <rdivacky@FreeBSD.org> | 2009-10-23 14:22:18 +0000 |
commit | 73490b890977362d28dd6326843a1ecae413921d (patch) | |
tree | 3fdd91eae574e32453a4baf462961c742df2691a /include/clang/Basic | |
parent | a5f348eb914e67b51914117fac117c18c1f8d650 (diff) |
Update clang to r84949.vendor/clang/clang-r84949
Notes
Notes:
svn path=/vendor/clang/dist/; revision=198398
svn path=/vendor/clang/clang-r84949/; revision=198399; tag=vendor/clang/clang-r84949
Diffstat (limited to 'include/clang/Basic')
-rw-r--r-- | include/clang/Basic/Diagnostic.h | 27 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticParseKinds.td | 3 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 26 | ||||
-rw-r--r-- | include/clang/Basic/FileManager.h | 55 | ||||
-rw-r--r-- | include/clang/Basic/IdentifierTable.h | 25 | ||||
-rw-r--r-- | include/clang/Basic/OnDiskHashTable.h | 21 | ||||
-rw-r--r-- | include/clang/Basic/SourceManager.h | 27 | ||||
-rw-r--r-- | include/clang/Basic/TargetInfo.h | 17 |
8 files changed, 130 insertions, 71 deletions
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index 380192e9dae6..005aab3fa6a1 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -15,6 +15,7 @@ #define LLVM_CLANG_DIAGNOSTIC_H #include "clang/Basic/SourceLocation.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/type_traits.h" #include <string> #include <vector> @@ -43,7 +44,7 @@ namespace clang { DIAG_START_PARSE = DIAG_START_LEX + 300, DIAG_START_AST = DIAG_START_PARSE + 300, DIAG_START_SEMA = DIAG_START_AST + 100, - DIAG_START_ANALYSIS = DIAG_START_SEMA + 1000, + DIAG_START_ANALYSIS = DIAG_START_SEMA + 1100, DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS + 100 }; @@ -107,7 +108,7 @@ public: /// \brief Create a code modification hint that inserts the given /// code string at a specific location. static CodeModificationHint CreateInsertion(SourceLocation InsertionLoc, - const std::string &Code) { + llvm::StringRef Code) { CodeModificationHint Hint; Hint.InsertionLoc = InsertionLoc; Hint.CodeToInsert = Code; @@ -125,7 +126,7 @@ public: /// \brief Create a code modification hint that replaces the given /// source range with the given code string. static CodeModificationHint CreateReplacement(SourceRange RemoveRange, - const std::string &Code) { + llvm::StringRef Code) { CodeModificationHint Hint; Hint.RemoveRange = RemoveRange; Hint.InsertionLoc = RemoveRange.getBegin(); @@ -163,6 +164,10 @@ public: ak_nestednamespec, // NestedNameSpecifier * ak_declcontext // DeclContext * }; + + /// ArgumentValue - This typedef represents on argument value, which is a + /// union discriminated by ArgumentKind, with a value. + typedef std::pair<ArgumentKind, intptr_t> ArgumentValue; private: unsigned char AllExtensionsSilenced; // Used by __extension__ @@ -202,10 +207,17 @@ private: /// ArgToStringFn - A function pointer that converts an opaque diagnostic /// argument to a strings. This takes the modifiers and argument that was /// present in the diagnostic. + /// + /// The PrevArgs array (whose length is NumPrevArgs) indicates the previous + /// arguments formatted for this diagnostic. Implementations of this function + /// can use this information to avoid redundancy across arguments. + /// /// This is a hack to avoid a layering violation between libbasic and libsema. typedef void (*ArgToStringFnTy)(ArgumentKind Kind, intptr_t Val, const char *Modifier, unsigned ModifierLen, const char *Argument, unsigned ArgumentLen, + const ArgumentValue *PrevArgs, + unsigned NumPrevArgs, llvm::SmallVectorImpl<char> &Output, void *Cookie); void *ArgToStringCookie; @@ -310,9 +322,10 @@ public: void ConvertArgToString(ArgumentKind Kind, intptr_t Val, const char *Modifier, unsigned ModLen, const char *Argument, unsigned ArgLen, + const ArgumentValue *PrevArgs, unsigned NumPrevArgs, llvm::SmallVectorImpl<char> &Output) const { - ArgToStringFn(Kind, Val, Modifier, ModLen, Argument, ArgLen, Output, - ArgToStringCookie); + ArgToStringFn(Kind, Val, Modifier, ModLen, Argument, ArgLen, + PrevArgs, NumPrevArgs, Output, ArgToStringCookie); } void SetArgToStringFn(ArgToStringFnTy Fn, void *Cookie) { @@ -546,7 +559,7 @@ public: /// return Diag(...); operator bool() const { return true; } - void AddString(const std::string &S) const { + void AddString(llvm::StringRef S) const { assert(NumArgs < Diagnostic::MaxArguments && "Too many arguments to diagnostic!"); if (DiagObj) { @@ -581,7 +594,7 @@ public: }; inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, - const std::string &S) { + llvm::StringRef S) { DB.AddString(S); return DB; } diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index 6971df50cb55..19b0ea3932a5 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -201,6 +201,9 @@ def warn_expected_implementation : Warning< "@end must appear in an @implementation context">; def error_property_ivar_decl : Error< "property synthesize requires specification of an ivar">; +def warn_semicolon_before_method_nody : Warning< + "semicolon before method body is ignored">, + InGroup<DiagGroup<"semicolon-before-method-body">>; def err_expected_field_designator : Error< "expected a field designator, such as '.field = 4'">; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index b1222a3f84eb..7a87e244f77c 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -383,6 +383,8 @@ def note_ambig_member_ref_object_type : Note< "lookup in the object type %0 refers here">; def note_ambig_member_ref_scope : Note< "lookup from the current scope refers here">; +def err_qualified_member_nonclass : Error< + "qualified member access refers to a member in %0">; // C++ class members def err_storageclass_invalid_for_member : Error< @@ -785,9 +787,9 @@ def err_ovl_template_candidate : Note< def err_ovl_candidate_deleted : Note< "candidate function has been explicitly %select{made unavailable|deleted}0">; def err_ovl_builtin_binary_candidate : Note< - "built-in candidate operator %0 (%1, %2)">; + "built-in candidate %0">; def err_ovl_builtin_unary_candidate : Note< - "built-in candidate operator %0 (%1)">; + "built-in candidate %0">; def err_ovl_no_viable_function_in_init : Error< "no matching constructor for initialization of %0">; def err_ovl_ambiguous_init : Error<"call to constructor of %0 is ambiguous">; @@ -1112,7 +1114,17 @@ def err_explicit_instantiation_without_qualified_id_quals : Error< "qualifier in explicit instantiation of '%0%1' requires a template-id">; def err_explicit_instantiation_unqualified_wrong_namespace : Error< "explicit instantiation of %q0 must occur in %1">; - +def err_explicit_instantiation_undefined_member : Error< + "explicit instantiation of undefined %select{member class|member function|" + "static data member}0 %1 of class template %2">; +def err_explicit_instantiation_undefined_func_template : Error< + "explicit instantiation of undefined function template %0">; +def err_explicit_instantiation_declaration_after_definition : Error< + "explicit instantiation declaration (with 'extern') follows explicit " + "instantiation definition (without 'extern')">; +def note_explicit_instantiation_definition_here : Note< + "explicit instantiation definition is here">; + // C++ typename-specifiers def err_typename_nested_not_found : Error<"no type named %0 in %1">; def err_typename_nested_not_type : Error< @@ -1734,7 +1746,9 @@ def err_not_tag_in_scope : Error< def err_cannot_form_pointer_to_member_of_reference_type : Error< "cannot form a pointer-to-member to member %0 of reference type %1">; - +def err_incomplete_object_call : Error< + "incomplete type in call to object of type %0">; + def warn_condition_is_assignment : Warning<"using the result of an " "assignment as a condition without parentheses">, InGroup<Parentheses>; @@ -2156,6 +2170,8 @@ def err_break_not_in_loop_or_switch : Error< def err_default_not_in_switch : Error< "'default' statement not in switch statement">; def err_case_not_in_switch : Error<"'case' statement not in switch statement">; +def warn_bool_switch_condition : Warning< + "switch condition is a bool">; def warn_case_value_overflow : Warning< "overflow converting case value to switch condition type (%0 to %1)">; def err_duplicate_case : Error<"duplicate case value '%0'">; @@ -2187,7 +2203,7 @@ def ext_return_has_expr : ExtWarn< def ext_return_has_void_expr : Extension< "void %select{function|method}1 %0 should not return void expression">; def warn_noreturn_function_has_return_expr : Warning< - "function %0 declared 'noreturn' should not return">, DefaultError, + "function %0 declared 'noreturn' should not return">, InGroup<DiagGroup<"invalid-noreturn">>; def warn_falloff_noreturn_function : Warning< "function declared 'noreturn' should not return">, diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h index 7c9113c497ef..5e7ac4f3c859 100644 --- a/include/clang/Basic/FileManager.h +++ b/include/clang/Basic/FileManager.h @@ -71,16 +71,38 @@ public: } }; -// FIXME: This is a lightweight shim that is used by FileManager to cache -// 'stat' system calls. We will use it with PTH to identify if caching -// stat calls in PTH files is a performance win. +/// \brief Abstract interface for introducing a FileManager cache for 'stat' +/// system calls, which is used by precompiled and pretokenized headers to +/// improve performance. class StatSysCallCache { +protected: + llvm::OwningPtr<StatSysCallCache> NextStatCache; + public: virtual ~StatSysCallCache() {} - virtual int stat(const char *path, struct stat *buf) = 0; + virtual int stat(const char *path, struct stat *buf) { + if (getNextStatCache()) + return getNextStatCache()->stat(path, buf); + + return ::stat(path, buf); + } + + /// \brief Sets the next stat call cache in the chain of stat caches. + /// Takes ownership of the given stat cache. + void setNextStatCache(StatSysCallCache *Cache) { + NextStatCache.reset(Cache); + } + + /// \brief Retrieve the next stat call cache in the chain. + StatSysCallCache *getNextStatCache() { return NextStatCache.get(); } + + /// \brief Retrieve the next stat call cache in the chain, transferring + /// ownership of this cache (and, transitively, all of the remaining caches) + /// to the caller. + StatSysCallCache *takeNextStatCache() { return NextStatCache.take(); } }; -/// \brief A stat listener that can be used by FileManager to keep +/// \brief A stat "cache" that can be used by FileManager to keep /// track of the results of stat() calls that occur throughout the /// execution of the front end. class MemorizeStatCalls : public StatSysCallCache { @@ -144,13 +166,22 @@ public: FileManager(); ~FileManager(); - /// setStatCache - Installs the provided StatSysCallCache object within - /// the FileManager. Ownership of this object is transferred to the - /// FileManager. - void setStatCache(StatSysCallCache *statCache) { - StatCache.reset(statCache); - } - + /// \brief Installs the provided StatSysCallCache object within + /// the FileManager. + /// + /// Ownership of this object is transferred to the FileManager. + /// + /// \param statCache the new stat cache to install. Ownership of this + /// object is transferred to the FileManager. + /// + /// \param AtBeginning whether this new stat cache must be installed at the + /// beginning of the chain of stat caches. Otherwise, it will be added to + /// the end of the chain. + void addStatCache(StatSysCallCache *statCache, bool AtBeginning = false); + + /// \brief Removes the provided StatSysCallCache object from the file manager. + void removeStatCache(StatSysCallCache *statCache); + /// getDirectory - Lookup, cache, and verify the specified directory. This /// returns null if the directory doesn't exist. /// diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index 84c2fc910d11..e06dfbb2cf1b 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -75,13 +75,13 @@ public: /// This is intended to be used for string literals only: II->isStr("foo"). template <std::size_t StrLen> bool isStr(const char (&Str)[StrLen]) const { - return getLength() == StrLen-1 && !memcmp(getName(), Str, StrLen-1); + return getLength() == StrLen-1 && !memcmp(getNameStart(), Str, StrLen-1); } - /// getName - Return the actual string for this identifier. The returned - /// string is properly null terminated. + /// getNameStart - Return the beginning of the actual string for this + /// identifier. The returned string is properly null terminated. /// - const char *getName() const { + const char *getNameStart() const { if (Entry) return Entry->getKeyData(); // FIXME: This is gross. It would be best not to embed specific details // of the PTH file format here. @@ -101,8 +101,12 @@ public: // std::pair<IdentifierInfo, const char*>, where internal pointer // points to the external string data. const char* p = ((std::pair<IdentifierInfo, const char*>*) this)->second-2; - return (((unsigned) p[0]) - | (((unsigned) p[1]) << 8)) - 1; + return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1; + } + + /// getName - Return the actual identifier string. + llvm::StringRef getName() const { + return llvm::StringRef(getNameStart(), getLength()); } /// hasMacroDefinition - Return true if this identifier is #defined to some @@ -232,6 +236,8 @@ public: /// Unlike the version in IdentifierTable, this returns a pointer instead /// of a reference. If the pointer is NULL then the IdentifierInfo cannot /// be found. + // + // FIXME: Move to StringRef API. virtual IdentifierInfo* get(const char *NameStart, const char *NameEnd) = 0; }; @@ -333,8 +339,11 @@ public: return *II; } + IdentifierInfo &CreateIdentifierInfo(llvm::StringRef Name) { + return CreateIdentifierInfo(Name.begin(), Name.end()); + } - IdentifierInfo &get(const llvm::StringRef& Name) { + IdentifierInfo &get(llvm::StringRef Name) { return get(Name.begin(), Name.end()); } @@ -463,7 +472,7 @@ public: const IdentifierInfo *Name) { llvm::SmallString<100> SelectorName; SelectorName = "set"; - SelectorName.append(Name->getName(), Name->getName()+Name->getLength()); + SelectorName += Name->getName(); SelectorName[3] = toupper(SelectorName[3]); IdentifierInfo *SetterName = &Idents.get(SelectorName.data(), diff --git a/include/clang/Basic/OnDiskHashTable.h b/include/clang/Basic/OnDiskHashTable.h index 65245167d8d5..2184bf3c457c 100644 --- a/include/clang/Basic/OnDiskHashTable.h +++ b/include/clang/Basic/OnDiskHashTable.h @@ -25,27 +25,6 @@ namespace clang { -// Bernstein hash function: -// This is basically copy-and-paste from StringMap. This likely won't -// stay here, which is why I didn't both to expose this function from -// String Map. -inline unsigned BernsteinHash(const char* x) { - unsigned int R = 0; - for ( ; *x != '\0' ; ++x) R = R * 33 + *x; - return R + (R >> 5); -} - -inline unsigned BernsteinHash(const char* x, unsigned n) { - unsigned int R = 0; - for (unsigned i = 0 ; i < n ; ++i, ++x) R = R * 33 + *x; - return R + (R >> 5); -} - -inline unsigned BernsteinHashPartial(const char* x, unsigned n, unsigned R) { - for (unsigned i = 0 ; i < n ; ++i, ++x) R = R * 33 + *x; - return R + (R >> 5); -} - namespace io { typedef uint32_t Offset; diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 7eb988f005ec..8a69cba066b3 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -685,26 +685,19 @@ public: /// void PrintStats() const; - // Iteration over the source location entry table. - typedef std::vector<SrcMgr::SLocEntry>::const_iterator sloc_entry_iterator; - - sloc_entry_iterator sloc_entry_begin() const { - return SLocEntryTable.begin(); - } - - sloc_entry_iterator sloc_entry_end() const { - return SLocEntryTable.end(); - } - unsigned sloc_entry_size() const { return SLocEntryTable.size(); } - const SrcMgr::SLocEntry &getSLocEntry(FileID FID) const { - assert(FID.ID < SLocEntryTable.size() && "Invalid id"); + const SrcMgr::SLocEntry &getSLocEntry(unsigned ID) const { + assert(ID < SLocEntryTable.size() && "Invalid id"); if (ExternalSLocEntries && - FID.ID < SLocEntryLoaded.size() && - !SLocEntryLoaded[FID.ID]) - ExternalSLocEntries->ReadSLocEntry(FID.ID); - return SLocEntryTable[FID.ID]; + ID < SLocEntryLoaded.size() && + !SLocEntryLoaded[ID]) + ExternalSLocEntries->ReadSLocEntry(ID); + return SLocEntryTable[ID]; + } + + const SrcMgr::SLocEntry &getSLocEntry(FileID FID) const { + return getSLocEntry(FID.ID); } unsigned getNextOffset() const { return NextOffset; } diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h index a1e0a17c882e..b88e2aaba383 100644 --- a/include/clang/Basic/TargetInfo.h +++ b/include/clang/Basic/TargetInfo.h @@ -83,7 +83,7 @@ public: }; protected: IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, IntPtrType, WCharType, - Char16Type, Char32Type, Int64Type; + WIntType, Char16Type, Char32Type, Int64Type; public: IntType getSizeType() const { return SizeType; } IntType getIntMaxType() const { return IntMaxType; } @@ -93,10 +93,20 @@ public: } IntType getIntPtrType() const { return IntPtrType; } IntType getWCharType() const { return WCharType; } + IntType getWIntType() const { return WIntType; } IntType getChar16Type() const { return Char16Type; } IntType getChar32Type() const { return Char32Type; } IntType getInt64Type() const { return Int64Type; } + + /// getTypeWidth - Return the width (in bits) of the specified integer type + /// enum. For example, SignedInt -> getIntWidth(). + unsigned getTypeWidth(IntType T) const; + + /// getTypeSigned - Return whether an integer types is signed. Returns true if + /// the type is signed; false otherwise. + bool getTypeSigned(IntType T) const; + /// getPointerWidth - Return the width of pointers on this target, for the /// specified address space. uint64_t getPointerWidth(unsigned AddrSpace) const { @@ -185,6 +195,10 @@ public: /// For example, SignedShort -> "short". static const char *getTypeName(IntType T); + /// getTypeConstantSuffix - Return the constant suffix for the specified + /// integer type enum. For example, SignedLong -> "L". + static const char *getTypeConstantSuffix(IntType T); + ///===---- Other target property query methods --------------------------===// /// getTargetDefines - Appends the target-specific #define values for this @@ -192,6 +206,7 @@ public: virtual void getTargetDefines(const LangOptions &Opts, std::vector<char> &DefineBuffer) const = 0; + /// getTargetBuiltins - Return information about target-specific builtins for /// the current primary target, and info about which builtins are non-portable /// across the current set of primary and secondary targets. |