aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/NestedNameSpecifier.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AST/NestedNameSpecifier.cpp')
-rw-r--r--lib/AST/NestedNameSpecifier.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/lib/AST/NestedNameSpecifier.cpp b/lib/AST/NestedNameSpecifier.cpp
index b03c4e09fa46..1f041aa49542 100644
--- a/lib/AST/NestedNameSpecifier.cpp
+++ b/lib/AST/NestedNameSpecifier.cpp
@@ -30,7 +30,7 @@ NestedNameSpecifier::FindOrInsert(const ASTContext &Context,
llvm::FoldingSetNodeID ID;
Mockup.Profile(ID);
- void *InsertPos = 0;
+ void *InsertPos = nullptr;
NestedNameSpecifier *NNS
= Context.NestedNameSpecifiers.FindNodeOrInsertPos(ID, InsertPos);
if (!NNS) {
@@ -61,7 +61,8 @@ NestedNameSpecifier::Create(const ASTContext &Context,
const NamespaceDecl *NS) {
assert(NS && "Namespace cannot be NULL");
assert((!Prefix ||
- (Prefix->getAsType() == 0 && Prefix->getAsIdentifier() == 0)) &&
+ (Prefix->getAsType() == nullptr &&
+ Prefix->getAsIdentifier() == nullptr)) &&
"Broken nested name specifier");
NestedNameSpecifier Mockup;
Mockup.Prefix.setPointer(Prefix);
@@ -76,7 +77,8 @@ NestedNameSpecifier::Create(const ASTContext &Context,
NamespaceAliasDecl *Alias) {
assert(Alias && "Namespace alias cannot be NULL");
assert((!Prefix ||
- (Prefix->getAsType() == 0 && Prefix->getAsIdentifier() == 0)) &&
+ (Prefix->getAsType() == nullptr &&
+ Prefix->getAsIdentifier() == nullptr)) &&
"Broken nested name specifier");
NestedNameSpecifier Mockup;
Mockup.Prefix.setPointer(Prefix);
@@ -101,7 +103,7 @@ NestedNameSpecifier *
NestedNameSpecifier::Create(const ASTContext &Context, IdentifierInfo *II) {
assert(II && "Identifier cannot be NULL");
NestedNameSpecifier Mockup;
- Mockup.Prefix.setPointer(0);
+ Mockup.Prefix.setPointer(nullptr);
Mockup.Prefix.setInt(StoredIdentifier);
Mockup.Specifier = II;
return FindOrInsert(Context, Mockup);
@@ -117,7 +119,7 @@ NestedNameSpecifier::GlobalSpecifier(const ASTContext &Context) {
}
NestedNameSpecifier::SpecifierKind NestedNameSpecifier::getKind() const {
- if (Specifier == 0)
+ if (!Specifier)
return Global;
switch (Prefix.getInt()) {
@@ -144,7 +146,7 @@ NamespaceDecl *NestedNameSpecifier::getAsNamespace() const {
if (Prefix.getInt() == StoredNamespaceOrAlias)
return dyn_cast<NamespaceDecl>(static_cast<NamedDecl *>(Specifier));
- return 0;
+ return nullptr;
}
/// \brief Retrieve the namespace alias stored in this nested name
@@ -153,7 +155,7 @@ NamespaceAliasDecl *NestedNameSpecifier::getAsNamespaceAlias() const {
if (Prefix.getInt() == StoredNamespaceOrAlias)
return dyn_cast<NamespaceAliasDecl>(static_cast<NamedDecl *>(Specifier));
- return 0;
+ return nullptr;
}
@@ -437,7 +439,7 @@ namespace {
NestedNameSpecifierLocBuilder::
NestedNameSpecifierLocBuilder(const NestedNameSpecifierLocBuilder &Other)
- : Representation(Other.Representation), Buffer(0),
+ : Representation(Other.Representation), Buffer(nullptr),
BufferSize(0), BufferCapacity(0)
{
if (!Other.Buffer)
@@ -451,10 +453,8 @@ NestedNameSpecifierLocBuilder(const NestedNameSpecifierLocBuilder &Other)
}
// Deep copy
- BufferSize = Other.BufferSize;
- BufferCapacity = Other.BufferSize;
- Buffer = static_cast<char *>(malloc(BufferCapacity));
- memcpy(Buffer, Other.Buffer, BufferSize);
+ Append(Other.Buffer, Other.Buffer + Other.BufferSize, Buffer, BufferSize,
+ BufferCapacity);
}
NestedNameSpecifierLocBuilder &
@@ -477,7 +477,7 @@ operator=(const NestedNameSpecifierLocBuilder &Other) {
if (!Other.Buffer) {
// Empty.
- Buffer = 0;
+ Buffer = nullptr;
BufferSize = 0;
return *this;
}
@@ -490,10 +490,8 @@ operator=(const NestedNameSpecifierLocBuilder &Other) {
}
// Deep copy.
- BufferSize = Other.BufferSize;
- BufferCapacity = BufferSize;
- Buffer = static_cast<char *>(malloc(BufferSize));
- memcpy(Buffer, Other.Buffer, BufferSize);
+ Append(Other.Buffer, Other.Buffer + Other.BufferSize, Buffer, BufferSize,
+ BufferCapacity);
return *this;
}
@@ -599,7 +597,7 @@ void NestedNameSpecifierLocBuilder::Adopt(NestedNameSpecifierLoc Other) {
free(Buffer);
if (!Other) {
- Representation = 0;
+ Representation = nullptr;
BufferSize = 0;
return;
}