diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-01-17 02:15:54 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-01-17 02:15:54 +0000 |
commit | 5e192a7d60e776fa65e633cd9c2a0d59df132f23 (patch) | |
tree | 12946b8d9e1320020de2f27e0b0c27021bc055a1 | |
parent | ea8c59aaa6bd19976879142296f8fd12f8926738 (diff) |
[libclang] Make clang_getCursorCompletionString not depend on the ASTUnit having
a Sema.
This allows it to work when Sema is not available, like when loading AST files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148279 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/libclang/CXCursor.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp index 1b8af395e2..fb70d9a0f6 100644 --- a/tools/libclang/CXCursor.cpp +++ b/tools/libclang/CXCursor.cpp @@ -1021,30 +1021,28 @@ CXCompletionString clang_getCursorCompletionString(CXCursor cursor) { Decl *decl = getCursorDecl(cursor); if (NamedDecl *namedDecl = dyn_cast_or_null<NamedDecl>(decl)) { ASTUnit *unit = getCursorASTUnit(cursor); - if (unit->hasSema()) { - Sema &S = unit->getSema(); - CodeCompletionAllocator *Allocator - = unit->getCursorCompletionAllocator().getPtr(); - CodeCompletionResult Result(namedDecl); - CodeCompletionString *String - = Result.CreateCodeCompletionString(S, *Allocator); - return String; - } + CodeCompletionAllocator *Allocator + = unit->getCursorCompletionAllocator().getPtr(); + CodeCompletionResult Result(namedDecl); + CodeCompletionString *String + = Result.CreateCodeCompletionString(unit->getASTContext(), + unit->getPreprocessor(), + *Allocator); + return String; } } else if (kind == CXCursor_MacroDefinition) { MacroDefinition *definition = getCursorMacroDefinition(cursor); const IdentifierInfo *MacroInfo = definition->getName(); ASTUnit *unit = getCursorASTUnit(cursor); - if (unit->hasSema()) { - Sema &S = unit->getSema(); - CodeCompletionAllocator *Allocator - = unit->getCursorCompletionAllocator().getPtr(); - CodeCompletionResult Result(const_cast<IdentifierInfo *>(MacroInfo)); - CodeCompletionString *String - = Result.CreateCodeCompletionString(S, *Allocator); - return String; - } + CodeCompletionAllocator *Allocator + = unit->getCursorCompletionAllocator().getPtr(); + CodeCompletionResult Result(const_cast<IdentifierInfo *>(MacroInfo)); + CodeCompletionString *String + = Result.CreateCodeCompletionString(unit->getASTContext(), + unit->getPreprocessor(), + *Allocator); + return String; } return NULL; } |