diff options
| author | Ted Kremenek <kremenek@apple.com> | 2010-01-18 22:02:49 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2010-01-18 22:02:49 +0000 |
| commit | a6980af2d2aa34734748550e7d639e867af5eb43 (patch) | |
| tree | 157fe2f1739ddeb8f94d93fcc71f6084ae00f24b | |
| parent | e7b52f2e87db78d5cc5b20fcb097234a3e7bd4d8 (diff) | |
| download | bcm5719-llvm-a6980af2d2aa34734748550e7d639e867af5eb43.tar.gz bcm5719-llvm-a6980af2d2aa34734748550e7d639e867af5eb43.zip | |
Tweak USR generation to handle anonymous bitfields.
llvm-svn: 93778
| -rw-r--r-- | clang/tools/CIndex/CIndexUSRs.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/clang/tools/CIndex/CIndexUSRs.cpp b/clang/tools/CIndex/CIndexUSRs.cpp index c8933fa000e..bd88ab44b83 100644 --- a/clang/tools/CIndex/CIndexUSRs.cpp +++ b/clang/tools/CIndex/CIndexUSRs.cpp @@ -70,12 +70,16 @@ static inline Program &GetProgram(CXIndex CIdx) { namespace { class USRGenerator : public DeclVisitor<USRGenerator> { llvm::raw_ostream &Out; + bool IgnoreResults; public: - USRGenerator(llvm::raw_ostream &out) : Out(out) {} + USRGenerator(llvm::raw_ostream &out) : Out(out), IgnoreResults(false) {} + + bool ignoreResults() const { return IgnoreResults; } void VisitBlockDecl(BlockDecl *D); void VisitDeclContext(DeclContext *D); void VisitEnumDecl(EnumDecl *D); + void VisitFieldDecl(FieldDecl *D); void VisitFunctionDecl(FunctionDecl *D); void VisitNamedDecl(NamedDecl *D); void VisitNamespaceDecl(NamespaceDecl *D); @@ -105,6 +109,17 @@ void USRGenerator::VisitEnumDecl(EnumDecl *D) { VisitTagDeclCommon(D); } +void USRGenerator::VisitFieldDecl(FieldDecl *D) { + const std::string &s = D->getNameAsString(); + if (s.empty()) { + // Bit fields can be anonymous. + IgnoreResults = true; + return; + } + VisitDeclContext(D->getDeclContext()); + Out << "@^FI^" << s; +} + void USRGenerator::VisitFunctionDecl(FunctionDecl *D) { VisitDeclContext(D->getDeclContext()); Out << "@F^" << D->getNameAsString(); @@ -192,6 +207,8 @@ static CXString ConstructUSR(Decl *D) { llvm::raw_svector_ostream Out(StrBuf); USRGenerator UG(Out); UG.Visit(static_cast<Decl*>(D)); + if (UG.ignoreResults()) + return CIndexer::createCXString(NULL); } if (StrBuf.empty()) |

