I’m new to LLVM/Clang. This might be a dumb question, but it really confuses me.
According to the doc, ArrayRefdoes not own the underlying data, it is expected to be used in situations where the data resides in some other buffer, whose lifetime extends past that of the ArrayRef, so it is not in general safe to store an ArrayRef.
CompilerInvocation::CreateFromArgs stores the command-line args in its clang::CodeGenOptions by
This command-line args value is from:
It looks like SmallVector<const char *, 16> Args copies the input char* array and all of the objects that may host the resources will go out of the scope when this function returns. I’m wondering how can this CCArgs be safely stored as an ArrayRef in the CompilerInvocation object.