summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/NestedNameSpecifier.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST/NestedNameSpecifier.cpp')
-rw-r--r--clang/lib/AST/NestedNameSpecifier.cpp104
1 files changed, 52 insertions, 52 deletions
diff --git a/clang/lib/AST/NestedNameSpecifier.cpp b/clang/lib/AST/NestedNameSpecifier.cpp
index 503d0eb65e1..a514d57b6b6 100644
--- a/clang/lib/AST/NestedNameSpecifier.cpp
+++ b/clang/lib/AST/NestedNameSpecifier.cpp
@@ -85,7 +85,7 @@ NestedNameSpecifier::Create(const ASTContext &Context,
NestedNameSpecifier *
NestedNameSpecifier::Create(const ASTContext &Context,
- NestedNameSpecifier *Prefix,
+ NestedNameSpecifier *Prefix,
NamespaceAliasDecl *Alias) {
assert(Alias && "Namespace alias cannot be NULL");
assert((!Prefix ||
@@ -234,7 +234,7 @@ bool NestedNameSpecifier::isInstantiationDependent() const {
case Identifier:
// Identifier specifiers always represent dependent types
return true;
-
+
case Namespace:
case NamespaceAlias:
case Global:
@@ -284,7 +284,7 @@ NestedNameSpecifier::print(raw_ostream &OS,
case Namespace:
if (getAsNamespace()->isAnonymousNamespace())
return;
-
+
OS << getAsNamespace()->getName();
break;
@@ -348,7 +348,7 @@ LLVM_DUMP_METHOD void NestedNameSpecifier::dump() const {
print(llvm::errs(), PrintingPolicy(LO));
}
-unsigned
+unsigned
NestedNameSpecifierLoc::getLocalDataLength(NestedNameSpecifier *Qualifier) {
assert(Qualifier && "Expected a non-NULL qualifier");
@@ -379,7 +379,7 @@ NestedNameSpecifierLoc::getLocalDataLength(NestedNameSpecifier *Qualifier) {
return Length;
}
-unsigned
+unsigned
NestedNameSpecifierLoc::getDataLength(NestedNameSpecifier *Qualifier) {
unsigned Length = 0;
for (; Qualifier; Qualifier = Qualifier->getPrefix())
@@ -394,7 +394,7 @@ static SourceLocation LoadSourceLocation(void *Data, unsigned Offset) {
memcpy(&Raw, static_cast<char *>(Data) + Offset, sizeof(unsigned));
return SourceLocation::getFromRawEncoding(Raw);
}
-
+
/// Load a (possibly unaligned) pointer from a given address and
/// offset.
static void *LoadPointer(void *Data, unsigned Offset) {
@@ -406,19 +406,19 @@ static void *LoadPointer(void *Data, unsigned Offset) {
SourceRange NestedNameSpecifierLoc::getSourceRange() const {
if (!Qualifier)
return SourceRange();
-
+
NestedNameSpecifierLoc First = *this;
while (NestedNameSpecifierLoc Prefix = First.getPrefix())
First = Prefix;
-
- return SourceRange(First.getLocalSourceRange().getBegin(),
+
+ return SourceRange(First.getLocalSourceRange().getBegin(),
getLocalSourceRange().getEnd());
}
SourceRange NestedNameSpecifierLoc::getLocalSourceRange() const {
if (!Qualifier)
return SourceRange();
-
+
unsigned Offset = getDataLength(Qualifier->getPrefix());
switch (Qualifier->getKind()) {
case NestedNameSpecifier::Global:
@@ -478,7 +478,7 @@ static void Append(char *Start, char *End, char *&Buffer, unsigned &BufferSize,
memcpy(Buffer + BufferSize, Start, End - Start);
BufferSize += End-Start;
}
-
+
/// Save a source location to the given buffer.
static void SaveSourceLocation(SourceLocation Loc, char *&Buffer,
unsigned &BufferSize, unsigned &BufferCapacity) {
@@ -487,7 +487,7 @@ static void SaveSourceLocation(SourceLocation Loc, char *&Buffer,
reinterpret_cast<char *>(&Raw) + sizeof(unsigned),
Buffer, BufferSize, BufferCapacity);
}
-
+
/// Save a pointer to the given buffer.
static void SavePointer(void *Ptr, char *&Buffer, unsigned &BufferSize,
unsigned &BufferCapacity) {
@@ -497,18 +497,18 @@ static void SavePointer(void *Ptr, char *&Buffer, unsigned &BufferSize,
}
NestedNameSpecifierLocBuilder::
-NestedNameSpecifierLocBuilder(const NestedNameSpecifierLocBuilder &Other)
+NestedNameSpecifierLocBuilder(const NestedNameSpecifierLocBuilder &Other)
: Representation(Other.Representation) {
if (!Other.Buffer)
return;
-
+
if (Other.BufferCapacity == 0) {
// Shallow copy is okay.
Buffer = Other.Buffer;
BufferSize = Other.BufferSize;
return;
}
-
+
// Deep copy
Append(Other.Buffer, Other.Buffer + Other.BufferSize, Buffer, BufferSize,
BufferCapacity);
@@ -518,72 +518,72 @@ NestedNameSpecifierLocBuilder &
NestedNameSpecifierLocBuilder::
operator=(const NestedNameSpecifierLocBuilder &Other) {
Representation = Other.Representation;
-
+
if (Buffer && Other.Buffer && BufferCapacity >= Other.BufferSize) {
// Re-use our storage.
BufferSize = Other.BufferSize;
memcpy(Buffer, Other.Buffer, BufferSize);
return *this;
}
-
+
// Free our storage, if we have any.
if (BufferCapacity) {
free(Buffer);
BufferCapacity = 0;
}
-
+
if (!Other.Buffer) {
// Empty.
Buffer = nullptr;
BufferSize = 0;
return *this;
}
-
+
if (Other.BufferCapacity == 0) {
// Shallow copy is okay.
Buffer = Other.Buffer;
BufferSize = Other.BufferSize;
return *this;
}
-
+
// Deep copy.
Append(Other.Buffer, Other.Buffer + Other.BufferSize, Buffer, BufferSize,
BufferCapacity);
return *this;
}
-void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
- SourceLocation TemplateKWLoc,
- TypeLoc TL,
+void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
+ SourceLocation TemplateKWLoc,
+ TypeLoc TL,
SourceLocation ColonColonLoc) {
- Representation = NestedNameSpecifier::Create(Context, Representation,
- TemplateKWLoc.isValid(),
+ Representation = NestedNameSpecifier::Create(Context, Representation,
+ TemplateKWLoc.isValid(),
TL.getTypePtr());
-
+
// Push source-location info into the buffer.
SavePointer(TL.getOpaqueData(), Buffer, BufferSize, BufferCapacity);
SaveSourceLocation(ColonColonLoc, Buffer, BufferSize, BufferCapacity);
}
-void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
+void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
IdentifierInfo *Identifier,
- SourceLocation IdentifierLoc,
+ SourceLocation IdentifierLoc,
SourceLocation ColonColonLoc) {
- Representation = NestedNameSpecifier::Create(Context, Representation,
+ Representation = NestedNameSpecifier::Create(Context, Representation,
Identifier);
-
+
// Push source-location info into the buffer.
SaveSourceLocation(IdentifierLoc, Buffer, BufferSize, BufferCapacity);
SaveSourceLocation(ColonColonLoc, Buffer, BufferSize, BufferCapacity);
}
-void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
+void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
NamespaceDecl *Namespace,
- SourceLocation NamespaceLoc,
+ SourceLocation NamespaceLoc,
SourceLocation ColonColonLoc) {
- Representation = NestedNameSpecifier::Create(Context, Representation,
+ Representation = NestedNameSpecifier::Create(Context, Representation,
Namespace);
-
+
// Push source-location info into the buffer.
SaveSourceLocation(NamespaceLoc, Buffer, BufferSize, BufferCapacity);
SaveSourceLocation(ColonColonLoc, Buffer, BufferSize, BufferCapacity);
@@ -591,20 +591,20 @@ void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
NamespaceAliasDecl *Alias,
- SourceLocation AliasLoc,
+ SourceLocation AliasLoc,
SourceLocation ColonColonLoc) {
Representation = NestedNameSpecifier::Create(Context, Representation, Alias);
-
+
// Push source-location info into the buffer.
SaveSourceLocation(AliasLoc, Buffer, BufferSize, BufferCapacity);
SaveSourceLocation(ColonColonLoc, Buffer, BufferSize, BufferCapacity);
}
-void NestedNameSpecifierLocBuilder::MakeGlobal(ASTContext &Context,
+void NestedNameSpecifierLocBuilder::MakeGlobal(ASTContext &Context,
SourceLocation ColonColonLoc) {
assert(!Representation && "Already have a nested-name-specifier!?");
Representation = NestedNameSpecifier::GlobalSpecifier(Context);
-
+
// Push source-location info into the buffer.
SaveSourceLocation(ColonColonLoc, Buffer, BufferSize, BufferCapacity);
}
@@ -620,12 +620,12 @@ void NestedNameSpecifierLocBuilder::MakeSuper(ASTContext &Context,
SaveSourceLocation(ColonColonLoc, Buffer, BufferSize, BufferCapacity);
}
-void NestedNameSpecifierLocBuilder::MakeTrivial(ASTContext &Context,
- NestedNameSpecifier *Qualifier,
+void NestedNameSpecifierLocBuilder::MakeTrivial(ASTContext &Context,
+ NestedNameSpecifier *Qualifier,
SourceRange R) {
Representation = Qualifier;
-
- // Construct bogus (but well-formed) source information for the
+
+ // Construct bogus (but well-formed) source information for the
// nested-name-specifier.
BufferSize = 0;
SmallVector<NestedNameSpecifier *, 4> Stack;
@@ -639,24 +639,24 @@ void NestedNameSpecifierLocBuilder::MakeTrivial(ASTContext &Context,
case NestedNameSpecifier::NamespaceAlias:
SaveSourceLocation(R.getBegin(), Buffer, BufferSize, BufferCapacity);
break;
-
+
case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate: {
TypeSourceInfo *TSInfo
= Context.getTrivialTypeSourceInfo(QualType(NNS->getAsType(), 0),
R.getBegin());
- SavePointer(TSInfo->getTypeLoc().getOpaqueData(), Buffer, BufferSize,
+ SavePointer(TSInfo->getTypeLoc().getOpaqueData(), Buffer, BufferSize,
BufferCapacity);
break;
}
-
+
case NestedNameSpecifier::Global:
case NestedNameSpecifier::Super:
break;
}
-
+
// Save the location of the '::'.
- SaveSourceLocation(Stack.empty()? R.getEnd() : R.getBegin(),
+ SaveSourceLocation(Stack.empty()? R.getEnd() : R.getBegin(),
Buffer, BufferSize, BufferCapacity);
}
}
@@ -670,8 +670,8 @@ void NestedNameSpecifierLocBuilder::Adopt(NestedNameSpecifierLoc Other) {
BufferSize = 0;
return;
}
-
- // Rather than copying the data (which is wasteful), "adopt" the
+
+ // Rather than copying the data (which is wasteful), "adopt" the
// pointer (which points into the ASTContext) but set the capacity to zero to
// indicate that we don't own it.
Representation = Other.getNestedNameSpecifier();
@@ -680,16 +680,16 @@ void NestedNameSpecifierLocBuilder::Adopt(NestedNameSpecifierLoc Other) {
BufferCapacity = 0;
}
-NestedNameSpecifierLoc
+NestedNameSpecifierLoc
NestedNameSpecifierLocBuilder::getWithLocInContext(ASTContext &Context) const {
if (!Representation)
return NestedNameSpecifierLoc();
-
+
// If we adopted our data pointer from elsewhere in the AST context, there's
// no need to copy the memory.
if (BufferCapacity == 0)
return NestedNameSpecifierLoc(Representation, Buffer);
-
+
// FIXME: After copying the source-location information, should we free
// our (temporary) buffer and adopt the ASTContext-allocated memory?
// Doing so would optimize repeated calls to getWithLocInContext().
OpenPOWER on IntegriCloud