[cfe-commits] r148279 - /cfe/trunk/tools/libclang/CXCursor.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Mon Jan 16 18:15:54 PST 2012
Author: akirtzidis
Date: Mon Jan 16 20:15:54 2012
New Revision: 148279
URL: http://llvm.org/viewvc/llvm-project?rev=148279&view=rev
Log:
[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.
Modified:
cfe/trunk/tools/libclang/CXCursor.cpp
Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=148279&r1=148278&r2=148279&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)
+++ cfe/trunk/tools/libclang/CXCursor.cpp Mon Jan 16 20:15:54 2012
@@ -1021,30 +1021,28 @@
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;
}
More information about the cfe-commits
mailing list