From 3665e00c87ba3f69f731e5254140ec4cd36807a9 Mon Sep 17 00:00:00 2001 From: John McCall Date: Fri, 23 Oct 2009 21:14:09 +0000 Subject: [PATCH] Add ASTContext::getTrivialDeclaratorInfo, which initializes a new source info block with a single location. llvm-svn: 84970 --- clang/include/clang/AST/ASTContext.h | 6 ++++++ clang/lib/AST/ASTContext.cpp | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 30896c91a143..66e69995c698 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1085,6 +1085,12 @@ public: /// should be calculated based on the type. DeclaratorInfo *CreateDeclaratorInfo(QualType T, unsigned Size = 0); + /// \brief Allocate a DeclaratorInfo where all locations have been + /// initialized to a given location, which defaults to the empty + /// location. + DeclaratorInfo * + getTrivialDeclaratorInfo(QualType T, SourceLocation Loc = SourceLocation()); + private: ASTContext(const ASTContext&); // DO NOT IMPLEMENT void operator=(const ASTContext&); // DO NOT IMPLEMENT diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 7f5fa35842af..3ece8c95a27a 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -955,6 +955,13 @@ DeclaratorInfo *ASTContext::CreateDeclaratorInfo(QualType T, return DInfo; } +DeclaratorInfo *ASTContext::getTrivialDeclaratorInfo(QualType T, + SourceLocation L) { + DeclaratorInfo *DI = CreateDeclaratorInfo(T); + DI->getTypeLoc().initialize(L); + return DI; +} + /// getInterfaceLayoutImpl - Get or compute information about the /// layout of the given interface. /// -- GitLab