mirror of
https://github.com/intel/llvm.git
synced 2026-02-07 16:11:27 +08:00
Added method "HandleTopLevelDeclaration" to ASTConsumer. This will eventually
be the new hook that ASTStreamer calls to feed top-level Decls to ASTConsumers. The difference between "HandleTopLevelDeclaration" and "HandleTopLevelDecl" is that "HandleTopLevelDecl" is currently called by ASTStreamer for every top-level declaration, including those that appear within a Decl chain. Using the new interface, ASTStreamer would only call HandleTopLevelDeclaration for Decls that appear that the beginning of a Decl chain (i.e., a group of related decls). To preserve the behavior that all subclasses of ASTConsumer currently expect, the default implementation of HandleTopLevelDeclaration simply calls HandleTopLevelDecl, and for decl chains it calls HandleTopLevelDecl for each Decl* in a chain of Decls. The advantage of this interface is that some subclasses of ASTConsumer only really want the Decl chain, and not each individual Decl passed to them. This extra level of indirection allows subclasses to override the default behavior if they so desire. llvm-svn: 44444
This commit is contained in:
27
clang/AST/ASTConsumer.cpp
Normal file
27
clang/AST/ASTConsumer.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
//===--- ASTConsumer.cpp - Abstract interface for reading ASTs --*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by Ted Kremenek and is distributed under
|
||||
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the ASTConsumer class.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/AST/ASTConsumer.h"
|
||||
#include "clang/AST/Decl.h"
|
||||
|
||||
using namespace clang;
|
||||
|
||||
void ASTConsumer::HandleTopLevelDeclaration(Decl* d) {
|
||||
if (ScopedDecl* sd = dyn_cast<ScopedDecl>(d))
|
||||
while (sd) {
|
||||
HandleTopLevelDecl(sd);
|
||||
sd = sd->getNextDeclarator();
|
||||
}
|
||||
else
|
||||
HandleTopLevelDecl(d);
|
||||
}
|
||||
Reference in New Issue
Block a user