Skip to content

Commit 53cefa2

Browse files
K-ballomizvekov
authored andcommitted
use system libs by default
1 parent 3948a8c commit 53cefa2

File tree

20 files changed

+81
-34
lines changed

20 files changed

+81
-34
lines changed

.clang-format

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,7 @@ IncludeCategories:
227227
# Comments
228228
FixNamespaceComments: true
229229
CommentPragmas: '^ clang-format'
230+
231+
---
232+
Language: Json
233+
BasedOnStyle: llvm

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ if (WIN32)
387387
mrdocs-core
388388
PUBLIC
389389
/permissive- # strict C++
390+
/Zc:__cplusplus # report C++ standard support
390391
/W4 # enable all warnings
391392
/MP # multi-processor compilation
392393
/EHs # C++ Exception handling

docs/modules/ROOT/pages/usage.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ It's also common for libraries to depend on the C++ standard library, the C stan
278278

279279
That means unless `-nostdinc` is defined, all systems include paths are included. This is what allows the user to also use headers like `<Windows.h>` or `<linux/version.h>` without explicitly including anything else, even though they are not part of the C standard library. This is often seen as a convenience but can lead to portability issues.
280280

281-
In this context, MrDocs provides the `use-system-stdlib` and `use-system-libc` options. Both are set as `false` by default, meaning MrDocs will compile the code as if the `-nostdinc&plus;&plus; -nostdlib&plus;&plus;` and `-nostdinc` flags were passed to Clang. Additionally:
281+
In this context, MrDocs provides the `use-system-stdlib` and `use-system-libc` options. Both are set as `true` by default; setting both to `false` results in MrDocs compiling the code as if the `-nostdinc&plus;&plus; -nostdlib&plus;&plus;` and `-nostdinc` flags were passed to Clang. Additionally:
282282

283283
- When `use-system-stdlib` is `false`, MrDocs will use the bundled libc&plus;&plus; headers available in `<mrdocs-root>/share/mrdocs/headers/libcxx` and `<mrdocs-root>/share/mrdocs/headers/clang`. These paths can be adjusted with the `stdlib-includes` option.
284284
- When `use-system-libc` is `false`, MrDocs will use the bundled libc stubs available in `<mrdocs-root>/share/mrdocs/headers/libc-stubs`. This path can be adjusted with the `libc-includes` option.

docs/mrdocs.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@
557557
"type": "string"
558558
},
559559
"use-system-libc": {
560-
"default": false,
560+
"default": true,
561561
"description": "To achieve reproducible results, MrDocs bundles the LibC headers with its definitions. To use the C standard library available in the system instead, set this option to true.",
562562
"enum": [
563563
true,
@@ -567,7 +567,7 @@
567567
"type": "boolean"
568568
},
569569
"use-system-stdlib": {
570-
"default": false,
570+
"default": true,
571571
"description": "To achieve reproducible results, MrDocs bundles the LibC++ headers. To use the C++ standard library available in the system instead, set this option to true.",
572572
"enum": [
573573
true,

docs/website/snippets/sqrt.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <type_traits>
2-
#include <stdexcept>
32

43
/** Computes the square root of an integral value.
54

src/lib/AST/ASTVisitor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2352,7 +2352,8 @@ extractSFINAEInfo(clang::QualType const T)
23522352
Result.Type = resultType->getAsType();
23532353
for (std::size_t I = 0; I < Args.size(); ++I)
23542354
{
2355-
if (SFINAEControl->ControllingParams[I])
2355+
if (I < SFINAEControl->ControllingParams.size()
2356+
&& SFINAEControl->ControllingParams[I])
23562357
{
23572358
MRDOCS_SYMBOL_TRACE(Args[I], context_);
23582359
clang::TemplateArgument ArgsI = Args[I];

src/lib/ConfigOptions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@
493493
"brief": "Use the system C++ standard library",
494494
"details": "To achieve reproducible results, MrDocs bundles the LibC++ headers. To use the C++ standard library available in the system instead, set this option to true.",
495495
"type": "bool",
496-
"default": false
496+
"default": true
497497
},
498498
{
499499
"name": "stdlib-includes",
@@ -513,7 +513,7 @@
513513
"brief": "Use the system C standard library",
514514
"details": "To achieve reproducible results, MrDocs bundles the LibC headers with its definitions. To use the C standard library available in the system instead, set this option to true.",
515515
"type": "bool",
516-
"default": false
516+
"default": true
517517
},
518518
{
519519
"name": "libc-includes",

src/lib/MrDocsSettingsDB.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "MrDocsSettingsDB.hpp"
1313
#include <mrdocs/Support/Path.hpp>
14+
#include <llvm/Support/Program.h>
1415

1516

1617
namespace mrdocs {
@@ -60,17 +61,18 @@ MrDocsSettingsDB::MrDocsSettingsDB(ConfigImpl const& config)
6061
});
6162
}
6263

64+
llvm::ErrorOr<std::string> clangPath = llvm::sys::findProgramByName(
65+
"clang");
66+
6367
for (auto const& pathName: sourceFiles)
6468
{
6569
// auto fileName = files::getFileName(pathName);
6670
auto parentDir = files::getParentDir(pathName);
6771

6872
std::vector<std::string> cmds;
69-
cmds.emplace_back("clang");
73+
cmds.emplace_back(clangPath ? *clangPath : "clang");
7074
cmds.emplace_back("-fsyntax-only");
7175
cmds.emplace_back("-std=c++23");
72-
cmds.emplace_back("-pedantic-errors");
73-
cmds.emplace_back("-Werror");
7476
cmds.emplace_back("-x");
7577
cmds.emplace_back("c++");
7678
cmds.emplace_back(pathName);

src/test/TestRunner.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ handleFile(
125125

126126
auto parentDir = files::getParentDir(filePath);
127127
std::unordered_map<std::string, std::vector<std::string>>
128-
defaultIncludePaths;
128+
defaultIncludePaths = {
129+
{ "clang", { MRDOCS_TEST_FILES_DIR "/include" } },
130+
{ "clang-cl", { MRDOCS_TEST_FILES_DIR "/include" } },
131+
};
129132

130133
// Test normally
131134
{

test-files/golden-tests/config/sfinae/redeclare.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ void f(std::enable_if_t<std::is_class_v<T>>);
1010

1111
template <typename T>
1212
void f(std::enable_if_t<std::is_class_v<T>>)
13-
{
14-
}
13+
{}

0 commit comments

Comments
 (0)