简体   繁体   English

编译llvm的Hello传递示例的错误

[英]Compile error for the Hello pass example of llvm

I was trying the Hello pass example in the "Writing an LLVM Pass" webpage. 我在“编写LLVM Pass”网页中尝试了Hello pass示例。 I followed the instructions to compile (with gcc-4.2) the Hello.cpp, but I got the compile errors: 我按照说明编译(使用gcc-4.2)Hello.cpp,但是我得到了编译错误:

Hello.cpp:20: error: expected identifier before string constant Hello.cpp:20:错误:字符串常量之前的预期标识符
Hello.cpp:20: error: expected ',' or '...' before string constant Hello.cpp:20:错误:在字符串常量之前预期','或'...'
Hello.cpp:20: error: expected constructor, destructor, or type conversion before ';' Hello.cpp:20:错误:在';'之前的预期构造函数,析构函数或类型转换 token 代币

which is the line INITIALIZE_PASS(Hello, "Hello", "Hello World Pass", false, false); 这是行INITIALIZE_PASS(Hello, "Hello", "Hello World Pass", false, false); in the program. 在该计划中。 The program is: 该计划是:

#include "llvm/Pass.h"  
#include "llvm/Function.h"  
#include "llvm/Support/raw_ostream.h"

using namespace llvm;

namespace {  

 struct Hello : public FunctionPass {  
    static char ID;  
    Hello() : FunctionPass(&ID) {}  

    virtual bool runOnFunction(Function &F) {  
        errs() << "Hello: " << F.getName() << "\n";  
        return false;  
    }  
 };  

 char Hello::ID = 0;  
 INITIALIZE_PASS(Hello, "Hello", "Hello World Pass", false, false);  
}

Could any one help me with this? 任何人都可以帮助我吗? Thank you very much! 非常感谢你!

Best, 最好,
Daniel 丹尼尔

This is the demo code. 这是演示代码。 This should work fine except for line 11, which should be: 这应该可以正常工作,除了第11行,它应该是:

    Hello() : FunctionPass(ID) {}

I am using llvm v2.8, and with that small change everything seems to be working well. 我正在使用llvm v2.8,并且通过这个小改动,一切似乎都运行良好。 But I renamed the program to something else as the Hello pass was already existing. 但是我将程序重命名为其他内容,因为Hello pass已经存在。

Follow the instructions in llvm v2.8, Writing an llvm pass 按照llvm v2.8中的说明编写llvm pass

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM