Example #1
0
// Argument taken as non-const ref because we need to be able to pass a
// non-const pointer to clang. This function (and clang too) will not modify the
// param though.
void TranslationUnit::Reparse( std::vector< CXUnsavedFile > &unsaved_files,
                               size_t parse_options ) {
  CXErrorCode failure;
  {
    unique_lock< mutex > lock( clang_access_mutex_ );

    if ( !clang_translation_unit_ ) {
      return;
    }

    CXUnsavedFile *unsaved = unsaved_files.empty()
                             ? nullptr : &unsaved_files[ 0 ];

    // This function should technically return a CXErrorCode enum but return an
    // int instead.
    failure = static_cast< CXErrorCode >(
      clang_reparseTranslationUnit( clang_translation_unit_,
                                    unsaved_files.size(),
                                    unsaved,
                                    parse_options ) );
  }

  if ( failure != CXError_Success ) {
    Destroy();
    throw ClangParseError( failure );
  }

  UpdateLatestDiagnostics();
}
Example #2
0
// Argument taken as non-const ref because we need to be able to pass a
// non-const pointer to clang. This function (and clang too) will not modify the
// param though.
void TranslationUnit::Reparse( std::vector< CXUnsavedFile > &unsaved_files,
                               size_t parse_options ) {
  int failure = 0;
  {
    unique_lock< mutex > lock( clang_access_mutex_ );

    if ( !clang_translation_unit_ )
      return;

    CXUnsavedFile *unsaved = unsaved_files.size() > 0
                             ? &unsaved_files[ 0 ] : NULL;

    failure = clang_reparseTranslationUnit( clang_translation_unit_,
                                            unsaved_files.size(),
                                            unsaved,
                                            parse_options );
  }

  if ( failure ) {
    Destroy();
    throw( ClangParseError() );
  }

  UpdateLatestDiagnostics();
}