🔳 COSCUP 2020 Taiwan
🔳 HackMD Note (https://bit.ly/libtooling)
🔳 Author Douglas Chen (陳鍵源 )
🔳 Clang frontend libraries:
◾ LibClang
◾ Clang Plugins
◾ LibTooling
◾ $ clang -cc1 -ast-dump min.c
🔳 Problems I got, then what I did:
◾ My side project
◾ Problems & Answers
🔳 Several naming conventions :
◾ UpperCamel,
◾ lowerCamel,
◾ UPPER_SNAKE_CASE,
◾ lower_snake_case,
◾ szHungarainNotion
🔳 Demonstrate to know more details by 10 questions
◾ #1: Parse input commands. (argc & argv) Command Library
◾ #2: Feed file path as a parameter ? loadFromFile()
◾ #3: How to get the name from Decls ?
◾ #4: Is it a(n) array / builtin-type / pointer ?
▪ QualType VarQualType = pVarDecl->getType();
▪ bIsArray = VarQualType->isArrayType();
▪ bIsBuiltinType = VarQualType->isBuiltinType();
▪ bIsPtr = VarQualType->isPointerType();
◾ #5: How to know its location (row & column)?
▪ ASTContext& AstCxt = pParamDecl->getASTContext();
▪ FullSourceLoc FullSrcLoc = AstCxt .getFullLoc(pDecl->getBeginLoc())
▪ size_t nLineNumb = FullSrcLoc.getSpellingLineNumber();
▪ size_t nColNumb = FullSrcLoc.getSpellingColumnNumber();
◾ #6: How to know parsing result ?
▪ pDecl->isInvalidDecl()
◾ #7: How to check a virtual file in memory ? (Unit Test)
▪ ClangTool::mapVirtualFile(VirtFileName, SourceCode);
◾ #8: How to check an header file ?
▪ getInsertArgumentAdjuster() "--language=c++"
▪ appendArgumentsAdjuster()
◾ #9: Specific header directories ?
▪ getInsertArgumentAdjuster() "-I %s"
▪ appendArgumentsAdjuster()
◾ #10: Absolute paths ?
▪ llvm::sys::fs::exists()
▪ llvm::sys::fs::access()
▪ llvm::sys::fs::make_absolute()
▪ llvm::sys::path::append()
▪ llvm::sys::path::is_relative()
▪ llvm::sys::path::is_absolute()
▪ llvm::sys::path::native()
▪ llvm::sys::path::filename()
▪ llvm::sys::path::extension()
🔳 The last
◾ CI/CD (Microsoft Azure DevOps)
◾ 創惟科技 (Genesys Logic)