aboutsummaryrefslogtreecommitdiff
path: root/odb/context.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-07-31 12:16:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-07-31 12:16:55 +0200
commit4fcb4ae749b3cf40f24ab1b9ddeb58b3ae0600f7 (patch)
tree6b6ad35e6895b7f1e8e81984fadc43ebfabd163e /odb/context.cxx
parent9c9b8f3a03951e1b7cc489ce0ec018a03520c039 (diff)
Add support for changing location that ODB views as class definition
This is useful for making third-party/system types into ODB composite value types. New pragma: definition. New test: common/definition.
Diffstat (limited to 'odb/context.cxx')
-rw-r--r--odb/context.cxx15
1 files changed, 12 insertions, 3 deletions
diff --git a/odb/context.cxx b/odb/context.cxx
index 693ada4..8335ec4 100644
--- a/odb/context.cxx
+++ b/odb/context.cxx
@@ -501,9 +501,18 @@ class_fq_name (semantics::class_& c)
semantics::path context::
class_file (semantics::class_& c)
{
- return c.is_a<semantics::class_instantiation> ()
- ? semantics::path (LOCATION_FILE (c.get<location_t> ("location")))
- : c.file ();
+ // If we have an explicit definition location, use that.
+ //
+ if (c.count ("definition"))
+ return semantics::path (LOCATION_FILE (c.get<location_t> ("definition")));
+ //
+ // Otherwise, if it is a template instantiation, use the location
+ // of the qualifier.
+ //
+ else if (c.is_a<semantics::class_instantiation> ())
+ return semantics::path (LOCATION_FILE (c.get<location_t> ("location")));
+ else
+ return c.file ();
}
string context::