Skip to content

Commit

Permalink
Make it possible to disable -nostdinc and -nostdinc++
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersbakken committed Aug 25, 2022
1 parent 9b77cac commit b9c680e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 26 deletions.
3 changes: 2 additions & 1 deletion src/ClangIndexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2236,7 +2236,8 @@ bool ClangIndexer::parse()
}

if (!unit) {
unit = RTags::TranslationUnit::create(mSourceFile, args, &unsavedFiles[0], unsavedIndex, flags, RTags::TranslationUnit::None);
unit = RTags::TranslationUnit::create(mSourceFile, args, &unsavedFiles[0], unsavedIndex, flags,
ClangIndexer::serverOpts() & Server::NoNoStdInc ? RTags::TranslationUnit::NoNoStdInc : NullFlags);
warning() << "CI::parse loading unit:" << unit->clangLine << " " << (unit->unit != nullptr);
}

Expand Down
3 changes: 3 additions & 0 deletions src/RTags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,9 @@ std::shared_ptr<TranslationUnit> TranslationUnit::create(const Path &sourceFile,
const int count = args.size();
for (int j=0; j<count; ++j) {
String arg = args.at(j);
if (createFlags & NoNoStdInc && (arg == "-nostdinc" || arg == "-nostdinc++")) {
continue;
}
clangArgs[idx++] = args.at(j).constData();
arg.replace("\"", "\\\"");
ret->clangLine += '"' + arg + '"';
Expand Down
3 changes: 2 additions & 1 deletion src/RTags.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ class TranslationUnit
bool reparse(CXUnsavedFile *unsaved, int unsavedCount);
enum CreateFlags {
None = 0x0,
DisplayDiagnostics = 0x1
DisplayDiagnostics = 0x1,
NoNoStdInc = 0x2
};
static std::shared_ptr<TranslationUnit> create(const Path &sourceFile,
const List<String> &args,
Expand Down
49 changes: 25 additions & 24 deletions src/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,30 +80,31 @@ class Server
NoFileManagerWatch = (1ull << 7),
NoFileSystemWatch = (1ull << 8),
NoNoUnknownWarningsOption = (1ull << 9),
SuspendRPOnCrash = (1ull << 10),
SeparateDebugAndRelease = (1ull << 11),
AllowPedantic = (1ull << 12),
StartSuspended = (1ull << 13),
EnableCompilerManager = (1ull << 14),
EnableNDEBUG = (1ull << 15),
Progress = (1ull << 16),
Weverything = (1ull << 17),
NoComments = (1ull << 18),
Launchd = (1ull << 19),
RPLogToSyslog = (1ull << 20),
CompletionsNoFilter = (1ull << 21),
WatchSourcesOnly = (1ull << 22),
NoFileLock = (1ull << 23),
PCHEnabled = (1ull << 24),
NoFileManager = (1ull << 25),
ValidateFileMaps = (1ull << 26),
CompletionLogs = (1ull << 27),
AllowWErrorAndWFatalErrors = (1ull << 28),
NoRealPath = (1ull << 29),
Separate32BitAnd64Bit = (1ull << 30),
SourceIgnoreIncludePathDifferencesInUsr = (1ull << 31),
NoLibClangIncludePath = (1ull << 32),
CompletionDiagnostics = (1ull << 33)
NoNoStdInc = (1ull << 10),
SuspendRPOnCrash = (1ull << 11),
SeparateDebugAndRelease = (1ull << 12),
AllowPedantic = (1ull << 13),
StartSuspended = (1ull << 14),
EnableCompilerManager = (1ull << 15),
EnableNDEBUG = (1ull << 16),
Progress = (1ull << 17),
Weverything = (1ull << 18),
NoComments = (1ull << 19),
Launchd = (1ull << 20),
RPLogToSyslog = (1ull << 21),
CompletionsNoFilter = (1ull << 22),
WatchSourcesOnly = (1ull << 23),
NoFileLock = (1ull << 24),
PCHEnabled = (1ull << 25),
NoFileManager = (1ull << 26),
ValidateFileMaps = (1ull << 27),
CompletionLogs = (1ull << 28),
AllowWErrorAndWFatalErrors = (1ull << 29),
NoRealPath = (1ull << 30),
Separate32BitAnd64Bit = (1ull << 31),
SourceIgnoreIncludePathDifferencesInUsr = (1ull << 32),
NoLibClangIncludePath = (1ull << 33),
CompletionDiagnostics = (1ull << 34)
};
struct Options {
Options()
Expand Down
5 changes: 5 additions & 0 deletions src/rdm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ enum OptionType {
NoStartupProject,
NoLibClangIncludePath,
NoNoUnknownWarningsOption,
NoNoStdInc,
IgnoreCompiler,
CompilerWrappers,
WatchSystemPaths,
Expand Down Expand Up @@ -332,6 +333,7 @@ int main(int argc, char** argv)
{ LargeByValueCopy, "large-by-value-copy", 'r', CommandLineParser::Required, "Use -Wlarge-by-value-copy=[arg] when invoking clang." },
{ NoStartupProject, "no-startup-project", 'o', CommandLineParser::NoValue, "Don't restore the last current project on startup." },
{ NoNoUnknownWarningsOption, "no-no-unknown-warnings-option", 'Y', CommandLineParser::NoValue, "Don't pass -Wno-unknown-warning-option." },
{ NoNoStdInc, "no-no-stdinc", 0, CommandLineParser::NoValue, "Don't pass -no-stdinc or -nostdinc++ even if otherwise asked to." },
{ IgnoreCompiler, "ignore-compiler", 'b', CommandLineParser::Required, "Ignore this compiler." },
{ CompilerWrappers, "compiler-wrappers", 0, CommandLineParser::Required, String::format("Consider these filenames compiler wrappers (split on ;), default \"%s\".", DEFAULT_COMPILER_WRAPPERS) },
{ WatchSystemPaths, "watch-system-paths", 'w', CommandLineParser::NoValue, "Watch system paths for changes." },
Expand Down Expand Up @@ -524,6 +526,9 @@ int main(int argc, char** argv)
case NoNoUnknownWarningsOption: {
serverOpts.options |= Server::NoNoUnknownWarningsOption;
break; }
case NoNoStdInc: {
serverOpts.options |= Server::NoNoStdInc;
break; }
case IgnoreCompiler: {
serverOpts.ignoredCompilers.insert(Path::resolved(value));
break; }
Expand Down

0 comments on commit b9c680e

Please sign in to comment.