예제 #1
0
파일: clang_test.py 프로젝트: 50417/phd
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); }
""")
예제 #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]))
예제 #3
0
파일: clang_test.py 프로젝트: 50417/phd
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)
예제 #4
0
파일: clang_test.py 프로젝트: 50417/phd
def test_Preprocess_empty_input():
    """Test that Preprocess accepts an empty input."""
    assert _StripPreprocessorLines(clang.Preprocess('')) == '\n'