Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/cxx-gen-ast/src/gen_ast_decoder_cc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function gen_ast_decoder_cc({
const className = makeClassName(m.type);
emit(` if (node->${snakeName}()) {`);
emit(` auto* inserter = &ast->${m.name};`);
emit(` for (std::size_t i = 0; i < node->${snakeName}()->size();`);
emit(` for (std::uint32_t i = 0; i < node->${snakeName}()->size();`);
emit(` ++i) {`);
emit(` *inserter = new (pool_) List(decode${className}(`);
emit(` node->${snakeName}()->Get(i),`);
Expand All @@ -100,7 +100,7 @@ export function gen_ast_decoder_cc({
const className = makeClassName(m.type);
emit(` if (node->${snakeName}()) {`);
emit(` auto* inserter = &ast->${m.name};`);
emit(` for (std::size_t i = 0; i < node->${snakeName}()->size();`);
emit(` for (std::uint32_t i = 0; i < node->${snakeName}()->size();`);
emit(` ++i) {`);
emit(` *inserter = new (pool_) List(decode${className}(`);
emit(` node->${snakeName}()->Get(i)));`);
Expand Down
14 changes: 14 additions & 0 deletions src/frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,17 @@ if (CXX_INSTALL_TOOLS)
EXPORT cxxTargets
)
endif()

add_custom_target(link_cxx_include ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx/include $<TARGET_FILE_DIR:cxx>/../lib/cxx/include
)

add_custom_command(
OUTPUT wasi-sysroot.timestamp
COMMAND ${CMAKE_COMMAND} -E copy_directory ${wasi_sysroot_SOURCE_DIR} $<TARGET_FILE_DIR:cxx>/../lib/wasi-sysroot
COMMAND ${CMAKE_COMMAND} -E touch wasi-sysroot.timestamp
)

add_custom_target(link_wasi_sysroot ALL
DEPENDS wasi-sysroot.timestamp
)
3 changes: 0 additions & 3 deletions src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

add_custom_target(link_wasi_sysroot ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${wasi_sysroot_SOURCE_DIR} wasi-sysroot)

add_subdirectory(cxx)

if (CXX_INSTALL_WASI_SYSROOT)
Expand Down
5 changes: 1 addition & 4 deletions src/lib/cxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

add_custom_target(link_cxx_include ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/include include)

file(GLOB_RECURSE HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/*")

install(
FILES ${HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cxx/include
)
)
8 changes: 4 additions & 4 deletions src/lsp/cxx/lsp/lsp_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,9 @@ void Server::operator()(DidChangeTextDocumentNotification notification) {
} visit{text};

auto contentChanges = notification.params().contentChanges();
const auto contentChangeCount = contentChanges.size();
const auto contentChangeCount = int(contentChanges.size());

for (std::size_t i = 0; i < contentChangeCount; ++i) {
for (int i = 0; i < contentChangeCount; ++i) {
std::visit(visit, contentChanges.at(i));
}

Expand Down Expand Up @@ -508,8 +508,8 @@ void Server::operator()(CompletionRequest request) {
auto completionItems = response.result<Vector<CompletionItem>>();

// cxx expects 1-based line and column numbers
cxxDocument->codeCompletionAt(std::move(source), line + 1, column + 1,
completionItems);
cxxDocument->codeCompletionAt(std::move(source), std::uint32_t(line + 1),
std::uint32_t(column + 1), completionItems);

sendToClient(response);
});
Expand Down
2 changes: 1 addition & 1 deletion src/lsp/cxx/lsp/lsp_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Server {
struct Text {
std::string value;
std::vector<std::size_t> lineStartOffsets;
int version = 0;
std::int64_t version = 0;

auto offsetAt(std::size_t line, std::size_t column) const -> std::size_t;

Expand Down
2 changes: 1 addition & 1 deletion src/lsp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ target_link_libraries(test_lsp
GTest::gtest_main
cxx-lsp)

gtest_discover_tests(test_lsp)
gtest_discover_tests(test_lsp DISCOVERY_MODE PRE_TEST)
6 changes: 2 additions & 4 deletions src/parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,11 @@ if (CXX_ENABLE_FLATBUFFERS)
BINARY_SCHEMAS_DIR ${CMAKE_CURRENT_BINARY_DIR}/cxx
FLAGS --cpp)

target_link_libraries(cxx-parser
PRIVATE $<BUILD_INTERFACE:cxx-ast-flatbuffers>
)

target_link_libraries(cxx-parser
PRIVATE $<BUILD_INTERFACE:flatbuffers::header-only>
)

add_dependencies(cxx-parser GENERATE_cxx-ast-flatbuffers)
else()
target_compile_definitions(cxx-parser PRIVATE CXX_NO_FLATBUFFERS)
endif()
Expand Down
181 changes: 92 additions & 89 deletions src/parser/cxx/flatbuffers/ast_decoder.cc

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/parser/cxx/lexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ auto Lexer::readToken() -> TokenKind {
const auto hasMoreChars = skipSpaces();

tokenIsClean_ = true;
tokenPos_ = pos_ - cbegin(source_);
tokenPos_ = int(pos_ - cbegin(source_));
text_.clear();

if (!hasMoreChars) return TokenKind::T_EOF_SYMBOL;
Expand Down Expand Up @@ -231,16 +231,16 @@ auto Lexer::readToken() -> TokenKind {

auto lookat_delimiter = [&]() -> bool {
if (LA() != ')') return false;
if (LA(delimiter.size() + 1) != '"') return false;
if (LA(int(delimiter.size() + 1)) != '"') return false;
for (std::size_t i = 0; i < delimiter.size(); ++i) {
if (LA(i + 1) != delimiter[i]) return false;
if (LA(int(i + 1)) != delimiter[i]) return false;
}
return true;
};

while (pos_ != end_) {
if (lookat_delimiter()) {
consume(delimiter.size() + 2);
consume(int(delimiter.size() + 2));
break;
}
consume();
Expand Down
2 changes: 1 addition & 1 deletion src/parser/cxx/lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Lexer {
[[nodiscard]] auto tokenPos() const -> int { return tokenPos_; }

[[nodiscard]] auto tokenLength() const -> std::uint32_t {
return (pos_ - cbegin(source_)) - tokenPos_;
return std::uint32_t((pos_ - cbegin(source_)) - tokenPos_);
}

[[nodiscard]] auto tokenIsClean() const -> bool { return tokenIsClean_; }
Expand Down
14 changes: 7 additions & 7 deletions src/parser/cxx/preprocessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ struct Preprocessor::Private {
[[nodiscard]] auto unaryExpression(TokList *&ts) -> long;
[[nodiscard]] auto primaryExpression(TokList *&ts) -> long;

[[nodiscard]] auto parseArguments(TokList *ts, int formalCount,
[[nodiscard]] auto parseArguments(TokList *ts, std::size_t formalCount,
bool ignoreComma = false)
-> std::tuple<std::vector<TokRange>, TokList *, const Hideset *>;

Expand All @@ -1241,8 +1241,8 @@ struct Preprocessor::ParseArguments {
Private &d;

template <std::sentinel_for<TokIterator> S>
auto operator()(TokIterator it, S last, int formalCount, bool ignoreComma)
-> std::optional<Result> {
auto operator()(TokIterator it, S last, std::size_t formalCount,
bool ignoreComma) -> std::optional<Result> {
if (!cxx::lookat(it, last, TokenKind::T_LPAREN)) {
cxx_runtime_error("expected '('");
return std::nullopt;
Expand Down Expand Up @@ -1381,7 +1381,7 @@ void PendingFileContent::setContent(std::optional<std::string> content) const {
sourceFile->headerProtection = d->checkHeaderProtection(sourceFile->tokens);

if (sourceFile->headerProtection) {
sourceFile->headerProtectionLevel = d->evaluating_.size();
sourceFile->headerProtectionLevel = int(d->evaluating_.size());

d->ifndefProtectedFiles_.insert_or_assign(
sourceFile->fileName, sourceFile->headerProtection->tok->text);
Expand Down Expand Up @@ -1871,8 +1871,8 @@ auto Preprocessor::Private::parseDirective(SourceFile *source, TokList *start)

dependencies_.clear();

const auto directiveKind = classifyDirective(directive->tok->text.data(),
directive->tok->text.length());
const auto directiveKind = classifyDirective(
directive->tok->text.data(), int(directive->tok->text.length()));

TokList *ts = directive->next;

Expand Down Expand Up @@ -2706,7 +2706,7 @@ auto Preprocessor::Private::instantiate(TokList *ts, const Hideset *hideset)
return ts;
}

auto Preprocessor::Private::parseArguments(TokList *ts, int formalCount,
auto Preprocessor::Private::parseArguments(TokList *ts, std::size_t formalCount,
bool ignoreComma)
-> std::tuple<std::vector<TokRange>, TokList *, const Hideset *> {
assert(lookat(ts, TokenKind::T_IDENTIFIER, TokenKind::T_LPAREN));
Expand Down
2 changes: 1 addition & 1 deletion src/parser/cxx/symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class ClassSymbol final : public ScopedSymbol {
std::vector<FunctionSymbol*> constructors_;
std::unique_ptr<TemplateInfo<ClassSymbol>> templateInfo_;
ClassSymbol* templateClass_ = nullptr;
int templateSepcializationIndex_ = 0;
std::size_t templateSepcializationIndex_ = 0;
std::size_t sizeInBytes_ = 0;
union {
std::uint32_t flags_{};
Expand Down
2 changes: 1 addition & 1 deletion tests/api_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ target_link_libraries(test_api
GTest::gtest_main
cxx-parser)

gtest_discover_tests(test_api)
gtest_discover_tests(test_api DISCOVERY_MODE PRE_TEST)