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 | 7890821b5b722d8f4def52e41a8851b0bfb62d95 (patch) | |
tree | f003ea7fb4730358a81a36e98e5301f3f98cd665 /clang/tools/libclang/CXCursor.cpp | |
parent | 8d05ca7dd2bf85a96eb90de9b89181c74976582e (diff) | |
download | bcm5719-llvm-7890821b5b722d8f4def52e41a8851b0bfb62d95.tar.gz bcm5719-llvm-7890821b5b722d8f4def52e41a8851b0bfb62d95.zip |
[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.
llvm-svn: 148279
Diffstat (limited to 'clang/tools/libclang/CXCursor.cpp')
-rw-r--r-- | clang/tools/libclang/CXCursor.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/clang/tools/libclang/CXCursor.cpp b/clang/tools/libclang/CXCursor.cpp index 1b8af395e22..fb70d9a0f6f 100644 --- a/clang/tools/libclang/CXCursor.cpp +++ b/clang/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; } |