Skip to content

Commit 6b02a42

Browse files
committed
do not delay template parsing (needed on Windows)
1 parent 51a8f06 commit 6b02a42

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Sources/idt/idt.cc

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,17 @@ class consumer : public clang::ASTConsumer {
618618

619619
struct action : clang::ASTFrontendAction {
620620
void ExecuteAction() override {
621+
clang::CompilerInstance &CI = getCompilerInstance();
621622
if (!include_header.empty())
622-
installPPCallbacks();
623+
installPPCallbacks(CI);
624+
625+
// Setting DelayedTemplateParsing to false is equivalent invoking Clang with
626+
// the -fno-delayed-template-parsing option. On Windows, Clang defaults to
627+
// -fdelayed-template-parsing behavior to more closely match MSVC behavior.
628+
// We do not want this behavior because it causes us to miss some expression
629+
// nodes in template functions.
630+
CI.getInvocation().getLangOpts().DelayedTemplateParsing = false;
631+
623632
clang::ASTFrontendAction::ExecuteAction();
624633
}
625634

@@ -632,10 +641,9 @@ struct action : clang::ASTFrontendAction {
632641
// Install a callback that will be invoked on every preprocessor include
633642
// statement. This is done so we can determine if a user-specified custom
634643
// include statment needs to be added if any annotations are added.
635-
void installPPCallbacks() {
636-
clang::CompilerInstance &compiler_instance = getCompilerInstance();
637-
clang::Preprocessor &preprocessor = compiler_instance.getPreprocessor();
638-
clang::SourceManager &source_manager = compiler_instance.getSourceManager();
644+
void installPPCallbacks(clang::CompilerInstance &CI) {
645+
clang::Preprocessor &preprocessor = CI.getPreprocessor();
646+
clang::SourceManager &source_manager = CI.getSourceManager();
639647
preprocessor.addPPCallbacks(
640648
std::make_unique<PPCallbacks>(source_manager, file_includes_));
641649
}

0 commit comments

Comments
 (0)