Skip to content

[clang] ASTImporter: fix SubstNonTypeTemplateParmExpr source location #135450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

mizvekov
Copy link
Contributor

@mizvekov mizvekov commented Apr 11, 2025

This makes it clear which source location is imported.

This fixes an issue where an incorrect source location is imported.
@mizvekov mizvekov self-assigned this Apr 11, 2025
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Apr 11, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 11, 2025

@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)

Changes

This fixes an issue where an incorrect source location is imported.


Full diff: https://github.com/llvm/llvm-project/pull/135450.diff

1 Files Affected:

  • (modified) clang/lib/AST/ASTImporter.cpp (+2-2)
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index f7cd54e447bbf..ab550d7aff5f1 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -8931,14 +8931,14 @@ ExpectedStmt ASTNodeImporter::VisitSubstNonTypeTemplateParmExpr(
     SubstNonTypeTemplateParmExpr *E) {
   Error Err = Error::success();
   auto ToType = importChecked(Err, E->getType());
-  auto ToExprLoc = importChecked(Err, E->getExprLoc());
+  auto ToNameLoc = importChecked(Err, E->getNameLoc());
   auto ToAssociatedDecl = importChecked(Err, E->getAssociatedDecl());
   auto ToReplacement = importChecked(Err, E->getReplacement());
   if (Err)
     return std::move(Err);
 
   return new (Importer.getToContext()) SubstNonTypeTemplateParmExpr(
-      ToType, E->getValueKind(), ToExprLoc, ToReplacement, ToAssociatedDecl,
+      ToType, E->getValueKind(), ToNameLoc, ToReplacement, ToAssociatedDecl,
       E->getIndex(), E->getPackIndex(), E->isReferenceParameter(),
       E->getFinal());
 }

@mizvekov mizvekov merged commit 6aae104 into main Apr 11, 2025
14 checks passed
@mizvekov mizvekov deleted the users/mizvekov/SubstNonTypeTemplateParmExpr-fix-import-sourceloc branch April 11, 2025 23:18
bcardosolopes added a commit to bcardosolopes/llvm-project that referenced this pull request Apr 12, 2025
* origin/main:
  [mlir][vector] Prevent folding non memref-type gather into maskedload (llvm#135371)
  [mlir][SMT] remove custom forall/exists builder because of asan memory leak
  [bazel] Fix a typo (llvm#135460)
  [bazel] Add support for SMT Dialect (llvm#135454)
  [clang] ASTImporter: fix SubstNonTypeTemplateParmExpr source location (llvm#135450)
  [RISCV] Don't fold offsets into auipc if offset is larger than the reference global variable. (llvm#135297)
  [gn] port d1fd977
  [NFC][LLVM] Apply std::move to object being pushed back in findSymbolCommon (llvm#135290)
  [AMDGPU] Teach iterative schedulers about IGLP (llvm#134953)
var-const pushed a commit to ldionne/llvm-project that referenced this pull request Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants