Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/AST/TypeLoc.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
SourceRange TypeLoc::getLocalSourceRangeImpl(TypeLoc TL) { | SourceRange TypeLoc::getLocalSourceRangeImpl(TypeLoc TL) { | ||||
if (TL.isNull()) return SourceRange(); | if (TL.isNull()) return SourceRange(); | ||||
return TypeLocRanger().Visit(TL); | return TypeLocRanger().Visit(TL); | ||||
} | } | ||||
namespace { | namespace { | ||||
class TypeNamer : public TypeLocVisitor<TypeNamer, llvm::StringRef> { | |||||
public: | |||||
#define ABSTRACT_TYPELOC(CLASS, PARENT) | |||||
#define TYPELOC(CLASS, PARENT) \ | |||||
llvm::StringRef Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { return #CLASS; } | |||||
#include "clang/AST/TypeLocNodes.def" | |||||
}; | |||||
} // namespace | |||||
llvm::StringRef TypeLoc::getTypeLocClassName() const { | |||||
return TypeNamer().Visit(*this); | |||||
} | |||||
aaron.ballman: It might make sense for this to return a `StringRef` instead so it's clear that the caller does… | |||||
namespace { | |||||
class TypeAligner : public TypeLocVisitor<TypeAligner, unsigned> { | class TypeAligner : public TypeLocVisitor<TypeAligner, unsigned> { | ||||
public: | public: | ||||
#define ABSTRACT_TYPELOC(CLASS, PARENT) | #define ABSTRACT_TYPELOC(CLASS, PARENT) | ||||
#define TYPELOC(CLASS, PARENT) \ | #define TYPELOC(CLASS, PARENT) \ | ||||
unsigned Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \ | unsigned Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \ | ||||
return TyLoc.getLocalDataAlignment(); \ | return TyLoc.getLocalDataAlignment(); \ | ||||
} | } | ||||
#include "clang/AST/TypeLocNodes.def" | #include "clang/AST/TypeLocNodes.def" | ||||
▲ Show 20 Lines • Show All 655 Lines • Show Last 20 Lines |
It might make sense for this to return a StringRef instead so it's clear that the caller does not own the memory or have to worry about releasing it. WDYT?