diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:36:24 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:36:24 +0000 |
commit | 36c5ade2f4674b544039d78db4c466756cf142b0 (patch) | |
tree | 3d3ed1e1987dbe6444294b1b4e249814b97b97a5 /lib/AST | |
parent | 51ece4aae5857052d224ce52277924c74685714e (diff) |
Notes
Diffstat (limited to 'lib/AST')
-rw-r--r-- | lib/AST/NSAPI.cpp | 22 | ||||
-rw-r--r-- | lib/AST/NestedNameSpecifier.cpp | 16 | ||||
-rw-r--r-- | lib/AST/RecordLayoutBuilder.cpp | 6 | ||||
-rw-r--r-- | lib/AST/Stmt.cpp | 13 |
4 files changed, 49 insertions, 8 deletions
diff --git a/lib/AST/NSAPI.cpp b/lib/AST/NSAPI.cpp index a9b10ed451c08..c9264d59aae35 100644 --- a/lib/AST/NSAPI.cpp +++ b/lib/AST/NSAPI.cpp @@ -9,6 +9,7 @@ #include "clang/AST/NSAPI.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/DeclObjC.h" #include "clang/AST/Expr.h" #include "llvm/ADT/StringSwitch.h" @@ -29,7 +30,6 @@ IdentifierInfo *NSAPI::getNSClassId(NSClassIdKindKind K) const { "NSMutableDictionary", "NSNumber", "NSMutableSet", - "NSCountedSet", "NSMutableOrderedSet", "NSValue" }; @@ -511,6 +511,26 @@ bool NSAPI::isMacroDefined(StringRef Id) const { return Ctx.Idents.get(Id).hasMacroDefinition(); } +bool NSAPI::isSubclassOfNSClass(ObjCInterfaceDecl *InterfaceDecl, + NSClassIdKindKind NSClassKind) const { + if (!InterfaceDecl) { + return false; + } + + IdentifierInfo *NSClassID = getNSClassId(NSClassKind); + + bool IsSubclass = false; + do { + IsSubclass = NSClassID == InterfaceDecl->getIdentifier(); + + if (IsSubclass) { + break; + } + } while ((InterfaceDecl = InterfaceDecl->getSuperClass())); + + return IsSubclass; +} + bool NSAPI::isObjCTypedef(QualType T, StringRef name, IdentifierInfo *&II) const { if (!Ctx.getLangOpts().ObjC1) diff --git a/lib/AST/NestedNameSpecifier.cpp b/lib/AST/NestedNameSpecifier.cpp index 50a00502ca9fc..97425d001de09 100644 --- a/lib/AST/NestedNameSpecifier.cpp +++ b/lib/AST/NestedNameSpecifier.cpp @@ -435,17 +435,19 @@ TypeLoc NestedNameSpecifierLoc::getTypeLoc() const { namespace { void Append(char *Start, char *End, char *&Buffer, unsigned &BufferSize, unsigned &BufferCapacity) { + if (Start == End) + return; + if (BufferSize + (End - Start) > BufferCapacity) { // Reallocate the buffer. - unsigned NewCapacity - = std::max((unsigned)(BufferCapacity? BufferCapacity * 2 - : sizeof(void*) * 2), - (unsigned)(BufferSize + (End - Start))); + unsigned NewCapacity = std::max( + (unsigned)(BufferCapacity ? BufferCapacity * 2 : sizeof(void *) * 2), + (unsigned)(BufferSize + (End - Start))); char *NewBuffer = static_cast<char *>(malloc(NewCapacity)); - memcpy(NewBuffer, Buffer, BufferSize); - - if (BufferCapacity) + if (BufferCapacity) { + memcpy(NewBuffer, Buffer, BufferSize); free(Buffer); + } Buffer = NewBuffer; BufferCapacity = NewCapacity; } diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp index 388c91c9cbc02..de7bcb826ebbc 100644 --- a/lib/AST/RecordLayoutBuilder.cpp +++ b/lib/AST/RecordLayoutBuilder.cpp @@ -2014,6 +2014,12 @@ static const CXXMethodDecl *computeKeyFunction(ASTContext &Context, continue; } + // If the key function is dllimport but the class isn't, then the class has + // no key function. The DLL that exports the key function won't export the + // vtable in this case. + if (MD->hasAttr<DLLImportAttr>() && !RD->hasAttr<DLLImportAttr>()) + return nullptr; + // We found it. return MD; } diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index c0aab4c4db7d3..e6292b4953657 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -724,6 +724,8 @@ MSAsmStmt::MSAsmStmt(const ASTContext &C, SourceLocation asmloc, } static StringRef copyIntoContext(const ASTContext &C, StringRef str) { + if (str.empty()) + return StringRef(); size_t size = str.size(); char *buffer = new (C) char[size]; memcpy(buffer, str.data(), size); @@ -1499,6 +1501,12 @@ void OMPLoopDirective::setCounters(ArrayRef<Expr *> A) { std::copy(A.begin(), A.end(), getCounters().begin()); } +void OMPLoopDirective::setInits(ArrayRef<Expr *> A) { + assert(A.size() == getCollapsedNumber() && + "Number of counter inits is not the same as the collapsed number"); + std::copy(A.begin(), A.end(), getInits().begin()); +} + void OMPLoopDirective::setUpdates(ArrayRef<Expr *> A) { assert(A.size() == getCollapsedNumber() && "Number of counter updates is not the same as the collapsed number"); @@ -1664,6 +1672,7 @@ OMPSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc, Dir->setInit(Exprs.Init); Dir->setInc(Exprs.Inc); Dir->setCounters(Exprs.Counters); + Dir->setInits(Exprs.Inits); Dir->setUpdates(Exprs.Updates); Dir->setFinals(Exprs.Finals); return Dir; @@ -1710,6 +1719,7 @@ OMPForDirective::Create(const ASTContext &C, SourceLocation StartLoc, Dir->setNextLowerBound(Exprs.NLB); Dir->setNextUpperBound(Exprs.NUB); Dir->setCounters(Exprs.Counters); + Dir->setInits(Exprs.Inits); Dir->setUpdates(Exprs.Updates); Dir->setFinals(Exprs.Finals); return Dir; @@ -1756,6 +1766,7 @@ OMPForSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc, Dir->setNextLowerBound(Exprs.NLB); Dir->setNextUpperBound(Exprs.NUB); Dir->setCounters(Exprs.Counters); + Dir->setInits(Exprs.Inits); Dir->setUpdates(Exprs.Updates); Dir->setFinals(Exprs.Finals); return Dir; @@ -1911,6 +1922,7 @@ OMPParallelForDirective *OMPParallelForDirective::Create( Dir->setNextLowerBound(Exprs.NLB); Dir->setNextUpperBound(Exprs.NUB); Dir->setCounters(Exprs.Counters); + Dir->setInits(Exprs.Inits); Dir->setUpdates(Exprs.Updates); Dir->setFinals(Exprs.Finals); return Dir; @@ -1955,6 +1967,7 @@ OMPParallelForSimdDirective *OMPParallelForSimdDirective::Create( Dir->setNextLowerBound(Exprs.NLB); Dir->setNextUpperBound(Exprs.NUB); Dir->setCounters(Exprs.Counters); + Dir->setInits(Exprs.Inits); Dir->setUpdates(Exprs.Updates); Dir->setFinals(Exprs.Finals); return Dir; |