Exemple #1
0
def test_Preprocess_small_cxx_program():
    """Test pre-processing a small C++ program."""
    assert clang.Preprocess("""
#define FOO T
template<typename FOO>
FOO foobar(const T& a) {return a;}

int foo() { return foobar<int>(10); }
""",
                            copts=['-xc++']).endswith("""

template<typename T>
T foobar(const T& a) {return a;}

int foo() { return foobar<int>(10); }
""")
Exemple #2
0
def ClangPreprocess(text: str) -> str:
    try:
        return clang.StripPreprocessorLines(
            clanglib.Preprocess(text, CLANG_ARGS))
    except llvm.LlvmError as e:
        raise errors.ClangException(str(e.stderr[:1024]))
Exemple #3
0
def test_Preprocess_missing_include():
    """Test that Preprocessor error is raised on missing #include."""
    with pytest.raises(clang.ClangException) as e_info:
        clang.Preprocess('#include "my-missing-file.h"')
    assert "'my-missing-file.h' file not found" in str(e_info)
Exemple #4
0
def test_Preprocess_empty_input():
    """Test that Preprocess accepts an empty input."""
    assert _StripPreprocessorLines(clang.Preprocess('')) == '\n'