Browse Source

Removed some maybe-dangerous use of auto. Added DefaultFlags, and using this as default parameter to for instance ReparseTranslationUnit.

merge-requests/37/head
eidheim 11 years ago
parent
commit
4cec716eac
  1. 2
      src/CompileCommands.cc
  2. 2
      src/CompletionString.cc
  3. 11
      src/TranslationUnit.cc
  4. 9
      src/TranslationUnit.h

2
src/CompileCommands.cc

@ -17,7 +17,7 @@ std::vector<clang::CompileCommand> clang::CompileCommands::
get_commands() { get_commands() {
unsigned N = clang_CompileCommands_getSize(commands_); unsigned N = clang_CompileCommands_getSize(commands_);
std::vector<clang::CompileCommand> res; std::vector<clang::CompileCommand> res;
for (auto i = 0; i < N; i++) { for (unsigned i = 0; i < N; i++) {
res.emplace_back(clang::CompileCommand(i, this)); res.emplace_back(clang::CompileCommand(i, this));
} }
return res; return res;

2
src/CompletionString.cc

@ -17,7 +17,7 @@ std::vector<clang::CompletionChunk> clang::CompletionString::
get_chunks() { get_chunks() {
std::vector<clang::CompletionChunk> res; std::vector<clang::CompletionChunk> res;
if (clang_getCompletionAvailability(str_) == CXAvailability_Available) { if (clang_getCompletionAvailability(str_) == CXAvailability_Available) {
for (auto i = 0; i < get_num_chunks(); i++) { for (size_t i = 0; i < get_num_chunks(); i++) {
res.emplace_back(clang_getCString(clang_getCompletionChunkText(str_, i)), res.emplace_back(clang_getCString(clang_getCompletionChunkText(str_, i)),
static_cast<CompletionChunkKind> static_cast<CompletionChunkKind>
(clang_getCompletionChunkKind(str_, i))); (clang_getCompletionChunkKind(str_, i)));

11
src/TranslationUnit.cc

@ -8,7 +8,6 @@ clang::TranslationUnit::
clang::TranslationUnit& clang::TranslationUnit:: clang::TranslationUnit& clang::TranslationUnit::
operator=(const clang::TranslationUnit &tu) { operator=(const clang::TranslationUnit &tu) {
tu_ = tu.tu_; tu_ = tu.tu_;
flags = tu.flags;
return *this; return *this;
} }
@ -43,7 +42,8 @@ clang::TranslationUnit::
TranslationUnit(clang::Index *index, TranslationUnit(clang::Index *index,
const std::string &filepath, const std::string &filepath,
const std::vector<std::string> &command_line_args, const std::vector<std::string> &command_line_args,
const std::map<std::string, std::string> &buffers) { const std::map<std::string, std::string> &buffers,
unsigned flags) {
std::vector<CXUnsavedFile> files; std::vector<CXUnsavedFile> files;
for (auto &buffer : buffers) { for (auto &buffer : buffers) {
CXUnsavedFile file; CXUnsavedFile file;
@ -68,7 +68,8 @@ TranslationUnit(clang::Index *index,
int clang::TranslationUnit:: int clang::TranslationUnit::
ReparseTranslationUnit(const std::string &file_path, ReparseTranslationUnit(const std::string &file_path,
const std::map<std::string, std::string> &buffers) { const std::map<std::string, std::string> &buffers,
unsigned flags) {
std::vector<CXUnsavedFile> files; std::vector<CXUnsavedFile> files;
for (auto &buffer : buffers) { for (auto &buffer : buffers) {
CXUnsavedFile file; CXUnsavedFile file;
@ -82,3 +83,7 @@ ReparseTranslationUnit(const std::string &file_path,
files.data(), files.data(),
flags); flags);
} }
unsigned clang::TranslationUnit::DefaultFlags() {
return CXTranslationUnit_CacheCompletionResults | CXTranslationUnit_PrecompiledPreamble | CXTranslationUnit_Incomplete;
}

9
src/TranslationUnit.h

@ -23,7 +23,8 @@ namespace clang {
TranslationUnit(Index *index, TranslationUnit(Index *index,
const std::string &filepath, const std::string &filepath,
const std::vector<std::string> &command_line_args, const std::vector<std::string> &command_line_args,
const std::map<std::string, std::string> &buffers); const std::map<std::string, std::string> &buffers,
unsigned flags=DefaultFlags());
TranslationUnit(Index *index, TranslationUnit(Index *index,
const std::string &filepath); const std::string &filepath);
~TranslationUnit(); ~TranslationUnit();
@ -31,8 +32,9 @@ namespace clang {
TranslationUnit& operator=(const TranslationUnit &tu); TranslationUnit& operator=(const TranslationUnit &tu);
int ReparseTranslationUnit(const std::string &file_path, int ReparseTranslationUnit(const std::string &file_path,
const std::map<std::string, std::string> const std::map<std::string, std::string>
&buffers); &buffers,
unsigned flags=DefaultFlags());
static unsigned DefaultFlags();
private: private:
friend Token; friend Token;
friend Tokens; friend Tokens;
@ -41,7 +43,6 @@ namespace clang {
friend Cursor; friend Cursor;
friend CodeCompleteResults; friend CodeCompleteResults;
CXTranslationUnit tu_; CXTranslationUnit tu_;
unsigned flags=CXTranslationUnit_CacheCompletionResults | CXTranslationUnit_PrecompiledPreamble | CXTranslationUnit_Incomplete;
}; };
} // namespace clang } // namespace clang
#endif // TRANSLATIONUNIT_H_ #endif // TRANSLATIONUNIT_H_

Loading…
Cancel
Save