#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/TextDiagnosticBuffer.h"
#include "llvm/Support/Host.h"
#include "gmock/gmock.h"
}
CommandLineTest()
- : Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions())) {}
+ : Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions(),
+ new TextDiagnosticBuffer())) {
+ }
};
TEST_F(CommandLineTest, OptIsInitializedWithCustomDefaultValue) {
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+ ASSERT_FALSE(Diags->hasErrorOccurred());
+
ASSERT_TRUE(Invocation.getFrontendOpts().UseTemporary);
}
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+ ASSERT_FALSE(Diags->hasErrorOccurred());
+
ASSERT_FALSE(Invocation.getFrontendOpts().UseTemporary);
}
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+ ASSERT_FALSE(Diags->hasErrorOccurred());
+
// Explicitly provided flag.
ASSERT_TRUE(Invocation.getLangOpts()->CLUnsafeMath);
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+ ASSERT_FALSE(Diags->hasErrorOccurred());
+
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fmodules-strict-context-hash")));
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+ ASSERT_FALSE(Diags->hasErrorOccurred());
+
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
ASSERT_THAT(GeneratedArgs, Contains(StrEq(TripleCStr)));
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+ ASSERT_FALSE(Diags->hasErrorOccurred());
+
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
// Triple should always be emitted even if it is the default
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+ ASSERT_FALSE(Diags->hasErrorOccurred());
+
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
// Triple should always be emitted even if it is the default
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+ ASSERT_FALSE(Diags->hasErrorOccurred());
+
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
// Non default relocation model.
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+ ASSERT_FALSE(Diags->hasErrorOccurred());
+
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
// Default relocation model.
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+ ASSERT_FALSE(Diags->hasErrorOccurred());
+
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-temp-file"))));
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+ ASSERT_FALSE(Diags->hasErrorOccurred());
+
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fno-temp-file")));
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+ ASSERT_FALSE(Diags->hasErrorOccurred());
+
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
// Missing options are not generated.
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+ ASSERT_FALSE(Diags->hasErrorOccurred());
+
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
// Missing options that were implied are not generated.
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+ ASSERT_FALSE(Diags->hasErrorOccurred());
+
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
// Present options that were also implied are not generated.
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+ ASSERT_FALSE(Diags->hasErrorOccurred());
+
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
// Present options that were not implied are generated.