Skip to content

Are the tutorials up-to-date? (Clang version is 20.0.0git) #114711

@bobhairgrove

Description

@bobhairgrove

Nothing written here seems to work for me: https://clang.llvm.org/docs/LibASTMatchersTutorial.html

In my previous post, I describe my frustrating experience building LLVM and Clang from latest sources. After having finally successfully built and installed everything after following a different tutorial found on the LLVM homepage, I went back to the LibASTMatcher tutorial to see if I could continue with the steps starting after the ninja install command (which should be sudo ninja install).

I didn't have ccmake installed (had to run sudo apt install cmake-curses-gui), so I did that. But I could not figure out where I needed to run this from since the tutorial installed everything immediately under $HOME and assumes that whoever is trying to use this tutorial would do the same. However, it seems that the step mentioned is to use clang to (re)compile LLVM using Clang, which isn't really necessary.

Then I went to this tutorial and tried to compile the very first example (using TEST() and EXPECT_TRUE(). It doesn't compile, unfortunately, but nothing written there gives me a hint about what is going on. Compiling with g++ should work, but here is the output:

// contents of "main.cpp":
#include "clang/Tooling/Tooling.h"

TEST(runToolOnCode, CanSyntaxCheckCode) {
  // runToolOnCode returns whether the action was correctly run over the
  // given code.
  EXPECT_TRUE(runToolOnCode(std::make_unique<clang::SyntaxOnlyAction>(), "class X {};"));
}

Output:

bob@bobs-laptop:~/code/LibToolingProject$ g++ -c main.cpp
main.cpp:3:5: error: expected constructor, destructor, or type conversion before ‘(’ token
    3 | TEST(runToolOnCode, CanSyntaxCheckCode) {
      |     ^

I know that TEST and EXPECT_TRUE are macros defined by Google test framework, but assume that they are somehow pulled in by the Tooling.h header. But perhaps not?

Why do the tutorial writers assume that certain tools are already installed without even mentioning the dependencies? Since all of these tutorials are located on the official LLVM and Clang websites, one would assume that they would be better organized and tested...

Metadata

Metadata

Assignees

Labels

clangClang issues not falling into any other categorydocumentationgood first issuehttps://github.com/llvm/llvm-project/contribute

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions