Move the 'ResolveLocationInAST' function from the Frontend library to the Index library.

Also, cut down its comments; more comments will be added to ASTLocation.

llvm-svn: 74860
This commit is contained in:
Argyrios Kyrtzidis 2009-07-06 21:35:02 +00:00
parent 63afa49add
commit f24249554b
4 changed files with 39 additions and 36 deletions

View File

@ -34,12 +34,6 @@ class PreprocessorFactory;
class LangOptions;
class Decl;
class Stmt;
class ASTContext;
class SourceLocation;
namespace idx {
class ASTLocation;
}
/// ProcessWarningOptions - Initialize the diagnostic client and process the
/// warning options specified on the command line.
@ -82,32 +76,6 @@ void AttachDependencyFileGen(Preprocessor *PP, llvm::raw_ostream *OS,
/// a seekable stream.
void CacheTokens(Preprocessor& PP, llvm::raw_fd_ostream* OS);
/// \brief Returns the AST node that a source location points to.
///
/// Returns a pair of Decl* and Stmt*. If no AST node is found for the source
/// location, the pair will contain null pointers.
///
/// If the source location points to just a declaration, the statement part of
/// the pair will be null, e.g.,
/// @code
/// int foo;
/// @endcode
/// If the source location points at 'foo', the pair will contain the VarDecl
/// of foo and a null Stmt.
///
/// If the source location points to a statement node, the returned declaration
/// will be the immediate 'parent' declaration of the statement node, e.g.,
/// @code
/// void f() {
/// int foo = 100;
/// ++foo;
/// }
/// @endcode
/// Pointing at '100' will return a <VarDecl 'foo', IntegerLiteral '100'> pair.
/// Pointing at '++foo' will return a <FunctionDecl 'f', UnaryOperator> pair.
///
idx::ASTLocation ResolveLocationInAST(ASTContext &Ctx, SourceLocation Loc);
} // end namespace clang
#endif

View File

@ -0,0 +1,35 @@
//===--- Utils.h - Misc utilities for indexing-----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This header contains miscellaneous utilities for indexing related
// functionality.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_INDEX_UTILS_H
#define LLVM_CLANG_INDEX_UTILS_H
namespace clang {
class ASTContext;
class SourceLocation;
namespace idx {
class ASTLocation;
/// \brief Returns the ASTLocation that a source location points to.
///
/// \returns the resolved ASTLocation or an invalid ASTLocation if the source
/// location could not be resolved.
ASTLocation ResolveLocationInAST(ASTContext &Ctx, SourceLocation Loc);
} // end namespace idx
} // end namespace clang
#endif

View File

@ -8,11 +8,11 @@
//===----------------------------------------------------------------------===//
//
// This defines the ResolveLocationInAST function, which resolves a
// source location into a <Decl *, Stmt *> pair.
// source location into a ASTLocation.
//
//===----------------------------------------------------------------------===//
#include "clang/Frontend/Utils.h"
#include "clang/Index/Utils.h"
#include "clang/Index/ASTLocation.h"
#include "clang/AST/DeclVisitor.h"
#include "clang/AST/StmtVisitor.h"
@ -322,7 +322,7 @@ void LocResolverBase::print(Stmt *Node) {
/// \brief Returns the AST node that a source location points to.
///
ASTLocation clang::ResolveLocationInAST(ASTContext &Ctx, SourceLocation Loc) {
ASTLocation idx::ResolveLocationInAST(ASTContext &Ctx, SourceLocation Loc) {
if (Loc.isInvalid())
return ASTLocation();

View File

@ -38,8 +38,8 @@
#include "clang/Index/TranslationUnit.h"
#include "clang/Index/ASTLocation.h"
#include "clang/Index/DeclReferenceMap.h"
#include "clang/Index/Utils.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/Utils.h"
#include "clang/Frontend/CommandLineSourceLoc.h"
#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"